Functions
comododir
Comodo.comododir — Function
comododir()Description
This function simply returns the string for the Comodo path. This is helpful for instance to load items, such as meshes, from the assets folder.
slidercontrol
Comodo.slidercontrol — Function
slidercontrol(hSlider,ax)Adds arrow key control to sliders
Description
This function adds arrow key control to Makie sliders. The inputs are the slider handle hSlider as well as the axis ax. If this function is called the slider can be advanced a step by pressing the right arrow, and returned one step by pressing the left arrow. When one presses and holds the right or left arrow key, the slider will continue to move (as fast as graphics updating is possible on your system) up to the end or start slider position respectively. Users may also use the up or down arrow keys. These function the same as the right and left arrow keys, however, rather than stopping at the slider extrema, the sliders position will "wrap" back to the start when advancing beyond the end position, and vice versa.
slider2anim
Comodo.slider2anim — Function
slider2anim(fig::Figure,hSlider::Slider,fileName::String; backforth=true, duration=2)Exports movies from slider based visualisations.
Description
Converts the effect of the slider defined by the slider handle hSlider for the figure fig to an animation/movie file
elements2indices
Comodo.elements2indices — Function
elements2indices(F)Returns the indices contained in F
Description
This function obtains the unique set of indices for the vertices (nodes) used by the the simplices defined by F. The vector F may contain any type of simplices. For instance the elements in F may be of the type GeometryBasics.TriangleFace or GeometryBasics.QuadFace (or any other) for surface mesh data. However, volumetric elements of any type are permitted. In essence this function simply returns unique(reduce(vcat,F)). Hence any suitable vector containing vectors of numbers permitted by reduce(vcat,F) is supported.
gridpoints
Comodo.gridpoints — Function
gridpoints(x::Vector{T}, y=x, z=x) where T<:RealReturns 3D grids of points
Description
The gridpoints function returns a vector of 3D points which span a grid in 3D space. Points are defined as per the input ranges or range vectors. The output point vector contains elements of the type Point.
gridpoints_equilateral
Comodo.gridpoints_equilateral — Function
gridpoints_equilateral(xSpan::Union{Vector{TT},Tuple{TT,TT}},ySpan::Union{Vector{TT},Tuple{TT,TT}},pointSpacing::T; return_faces::Val{B1} = Val(false), rectangular::Val{B2}=Val(false), force_equilateral::Val{B3}=Val(false)) where {T<:Real, TT<:Real, B1, B2, B3}Returns a "grid" of 3D points that are located on the corners of an equilateral triangle tesselation.
Description
This function returns 3D point data in the form of a Vector{Point{3,Float64}}. The point distribution is for an equilateral triangle tesselation. The input consists of the span in the x-, and y-direction, i.e. xSpan and ySpan respectively, as well as the desired pointSpacing. The "spans" should be vectors or tuples defining the minimum and maximum coordinates for the grid. The true point spacing in the x-direction is computed such that a nearest whole number of steps can cover the required distance. Next this spacing is used to create the equilateral triangle point grid. Although the xSpan is closely adhered to through this method, the ySpan is not fully covered. In the y-direction the grid does start at the minimum level, but may stop short of reaching the maximum y as it may not be reachable in a whole number of steps from the minimum. Optional arguments include return_faces (default is false), which will cause the function to return triangular faces F as well as the vertices V. Secondly the option rectangular will force the grid to conform to a rectangular domain. This means the "jagged" sides are forced to be flat such that all x-coordinates on the left are at the minimum in xSpan and all on the right are at the maximum in xSpan, however, this does result in a non-uniform spacing at these edges.
interp_biharmonic_spline
Comodo.interp_biharmonic_spline — Function
interp_biharmonic_spline(x::Union{Vector{T}, AbstractRange{T}},y::Union{Vector{T}, AbstractRange{T}},xi::Union{Vector{T}, AbstractRange{T}}; extrapolate_method=:linear,pad_data=:linear) where T<:RealInterpolates 1D (curve) data using biharmonic spline interpolation
Description
This function uses biharmonic spline interpolation [1], which features radial basis functions. The input is assumed to represent ordered data, i.e. consecutive unique points on a curve. The curve x-, and y-coordinates are provided through the input parameters x and y respectively. The third input xi defines the sites at which to interpolate. Each of in the input parameters can be either a vector or a range.
References
_greens_sq
Comodo._greens_sq — Function
_greens_sq(d_sq::T) where T<:RealGreen's function from squared distance
Description
A simple function to compute Green's function from a squared distance. The output is equivalent to g(d)= d^2 * (log(d)-1.0) where d is the non-squared distance. A squared distance can be derived from using Distances.sqeuclidean.
interp_biharmonic
Comodo.interp_biharmonic — Function
interp_biharmonic(x,y,xi)Interpolates n-dimensional data using biharmonic spline interpolation
Description
This function uses biharmonic interpolation [1]. The input x should define a vector consisting of m points which are n-dimensional, and the input y should be a vector consisting of m scalar data values.
References
nbezier
Comodo.nbezier — Function
nbezier(P,n)Returns a Bezier spline for the control points P whose order matches the number of control points provided.
Description
This function returns n points for an m-th order Bézier spline, based on the m control points contained in the input vector P. This function supports point vectors with elements of the type AbstractPoint{3} (e.g. Point{3, Float64}) or Vector{Float64}.
lerp
Comodo.lerp — Function
lerp(x::Union{T,Vector{T}, AbstractRange{T}},y,xi::Union{T,Vector{T}, AbstractRange{T}}) where T <: RealLinear interpolation
Description
This linearly interpolates (lerps) the input data specified by the sites x and data y at the specified site xi.
dist
Comodo.dist — Function
dist(V1,V2)Computes n-dimensional Euclidean distances
Description
Function compute an nxm distance matrix for the n inputs points in V1, and the m input points in V2. The input points may be multidimensional, in fact they can be any type supported by the euclidean function of Distances.jl. See also: https://github.com/JuliaStats/Distances.jl
mindist
Comodo.mindist — Function
mindist(V1,V2; getIndex=Val(false), skipSelf = false )Returns nearest point distances
Description
Returns the closest point distance for the input points V1 with respect to the input points V2. If the optional parameter getIndex is set to true (false by default) then this function also returns the indices of the nearest points in V2 for each point in V1. For self-distance evaluation, i.e. if the same point set is provided twice, then the optional parameter skipSelf can be set t0 true (default is false) if "self distances" (e.g. the nth point to the nth point) are to be avoided.
gunique
Comodo.gunique — Function
gunique(X; return_unique=true, return_index=false, return_inverse=false, return_counts=false, sort_entries=false)Returns unique values and allows users to choose if they also want: sorting, indices, inverse indices, and counts.
Description
Returns the unique entries in X. Depending on the optional parameter choices the indices for the unique entries, the reverse indices to retrieve the original from the unique entries, as well as counts in terms of how often they occured, can be returned. The optional parameter sort_entries (default is false) can be set to true if each entry in X should be sorted, this is helpful to allow the entry [1,2] to be seen as the same as [2,1] for instance.
unique_simplices
Comodo.unique_simplices — Function
unique_simplices(F,V=nothing)Returns unique simplices (such as faces), independent of node order
Description
Returns the unique simplices in F as well as the indices of the unique simplices and the reverse indices to retrieve the original faces from the unique faces. Entries in F are sorted such that the node order does not matter.
ind2sub
Comodo.ind2sub — Function
ind2sub(siz,ind)Converts linear indices to subscript indices. Assumes one-based indexing.
Description
shading = tru Converts the linear indices in ind, for a matrix/array with size siz, to the equivalent subscript indices.
sub2ind
Comodo.sub2ind — Function
sub2ind(siz,A)Converts subscript indices to linear indices. Assumes one-based indexing.
Description
Converts the subscript indices in A, for a matrix/array with size siz, to the equivalent linear indices.
meshedges
Comodo.meshedges — Function
meshedges(F::Array{NgonFace{N,T},1}; unique_only=false) where N where T<:IntegerReturns a mesh's edges.
Description
This function returns the edges E for the input faces defined by F. The input F can either represent a vector of faces or a GeometryBasics.Mesh. The convention is such that for a face referring to the nodes 1-2-3-4, the edges are 1-2, 2-3, 3-4, 4-1.
icosahedron
Comodo.icosahedron — Function
icosahedron(r=1.0)Creates an icosahedron mesh.
Description
Creates a GeometryBasics.Mesh for an icosahedron with radius r. The default radius, when not supplied, is 1.0.
octahedron
Comodo.octahedron — Function
octahedron(r=1.0)Creates an octahedron mesh.
Description
Creates a GeometryBasics.Mesh for an octahedron with radius r. The default radius, when not supplied, is 1.0.
dodecahedron
Comodo.dodecahedron — Function
dodecahedron(r=1.0)Creates a dodecahedron mesh.
Description
Creates a GeometryBasics.Mesh for an dodecahedron with radius r. The default radius, when not supplied, is 1.0.
cube
Comodo.cube — Function
cube(r=1.0)Creates a cube mesh.
Description
Creates a GeometryBasics.Mesh for an cube with radius r. The default radius, when not supplied, is 1.0.
tetrahedron
Comodo.tetrahedron — Function
tetrahedron(r=1.0)Creates a tetrahedron mesh.
Description
Creates a GeometryBasics.Mesh for an tetrahedron with radius r. The default radius, when not supplied, is 1.0.
platonicsolid
Comodo.platonicsolid — Function
platonicsolid(n,r=1.0)Returns a platonic solid mesh.
Description
Creates a GeometryBasics mesh description for a platonic solid of choice. The input n defines the choice.
- tetrahedron
- cube
- octahedron
- icosahedron
- dodecahedron
The final input parameter r defines the radius of the platonic solid (the radius of the circumsphere to the vertices). The default radius, when not supplied, is 1.0.
Arguments
n::Integer, defining platonic solid type r::Float64, defining circumsphere radius
tofaces
Comodo.tofaces — Function
tofaces(FM::Vector{Vector{TF}}) where TF<:Integer
tofaces(FM::Matrix{TF}) where TF<:Integer
tofaces(FM::Vector{NgonFace{m, OffsetInteger{-1, TF}}} ) where m where TF <: Integer
tofaces(FM::Vector{NgonFace{m, TF}} ) where m where TF <: IntegerConverts input to GeometryBasics compliant faces with standard integer types.
Description
The tofaces function converts "non-standard" (for Comodo) face set descriptions to "standard" ones. The following is considered such as standard: Vector{GeometryBasics.NgonFace{N,T}} where N where T<:Integer The input faces FM are converted to this format. FM can be of the following types:
FM::Vector{Vector{TF}} where TF<:Integer, whereby each Vector entry is
considered a face
FM::Matrix{TF} where TF<:Integer, whereby each row is considered a faceVector{NgonFace{m, OffsetInteger{-1, TF}}} where TF<:Integer, whereby the
special integer type OffsetInteger{-1, TF} is converted to Int. If the input is already of the right type this function leaves the input unchanged.
topoints
Comodo.topoints — Function
topoints(VM::Matrix{T}) where T<: Real
topoints(VM::Union{Array{Vec{N, T}, 1}, GeometryBasics.StructArray{TT,1} }) where TT <: AbstractPoint{N,T} where T <: Real where N
topoints(VM::Vector{Vector{T}}) where T <: Real
topoints(VM::Vector{Point{ND,TV}}) where ND where TV <: RealConverts input to GeometryBasics compliant simple points without meta content.
Description
The topoints function converts the "non-standard" (for Comodo) input points defined by VM to the "standard" format: VM::Vector{Point{ND,TV}} where ND where TV <: Real. For matrix input each row is considered a point. For vector input each vector entry is considered a point.
togeometrybasics_mesh
Comodo.togeometrybasics_mesh — Function
togeometrybasics_meshConverts the input to a GeometryBasics.Mesh
Description
This function converts the input faces F and vertices V to a GeometryBasics.Mesh. The function tofaces and topoints are used prior to conversion, to ensure standard faces and point types are used.
edgecrossproduct
Comodo.edgecrossproduct — Function
edgecrossproduct(V::Union{Vector{Point{ND,TV}}, StaticArraysCore.SVector{M, Point{ND, TV}}}) where ND where M where TV<:Real
edgecrossproduct(f::Union{NgonFace{NF,TF},Vector{TF},Tuple{Vararg{TF, NF}}}, V::Vector{Point{ND,TV}}) where NF where TF<:Integer where ND where TV<:Real
edgecrossproduct(F::Union{Vector{NgonFace{NF,TF}},Vector{Vector{TF}}, Vector{Tuple{Vararg{TF, NF}}}},V::Vector{Point{ND,TV}}) where NF where TF<:Integer where ND where TV<:RealReturns the edge cross product, useful for normal direction and area computations.
Description
This function computes the so-called edge-cross-product vector for polygons. The vector's length is the polygon area while the vector direction is the polygon normal direction. The input to the function is either a vector of points V that defines a single polygon, or a vector of faces F and vertices V, where each face defines a polygon.
facenormal
Comodo.facenormal — Function
facenormal(F,V)Returns the normal directions for each face.
Description
This function computes the per face normal directions for the input mesh defined either by the faces F and vertices V or by the GeometryBasics mesh M.
facearea
Comodo.facearea — Function
facearea(F,V)Returns the area for each face.
Description
This function computes the per face area for the input mesh defined either by the faces F and vertices V or by the GeometryBasics mesh M.
vertexnormal
Comodo.vertexnormal — Function
vertexnormal(F,V; weighting=:size)Returns the surface normal at each vertex.
Description
This function computes the per vertex surface normal directions for the input mesh defined either by the faces F and vertices V or by the GeometryBasics mesh M. The optional parameter weighting sets how the face normal directions are averaged onto the vertices. If weighting=:none a plain average for the surrounding faces is used. If instead weighting=:size (default), then the average is weighted based on the face areas.
edgelengths
Comodo.edgelengths — Function
edgelengths(E::LineFace,V)
edgelengths(F,V)
edgelengths(M::GeometryBasics.Mesh)Returns edge lengths.
Description
This function computes the lengths of the edges defined by edge vector E (e.g as obtained from meshedges(F,V), where F is a face vector, and V is a vector of vertices. Alternatively the input mesh can be a GeometryBasics mesh M.
subtri
Comodo.subtri — Function
subtri(F,V,n; method = :linear)
subtri(F,V,n; method = :Loop)Refines triangulations through splitting.
Description
The subtri function refines triangulated meshes iteratively. For each iteration each original input triangle is split into 4 triangles to form the refined mesh (one central one, and 3 at each corner). The following refinement methods are implemented:
method=:linear : This is the default method, and refines the triangles in a simple linear manor through splitting. Each input edge simply obtains a new mid-edge node.
method=:Loop : This method features Loop-subdivision [1,2]. Rather than linearly splitting edges and maintaining the original coordinates, as for the linear method, this method computes the new points in a special weighted sense such that the surface effectively approaches a "quartic box spline". Hence this method both refines and smoothes the geometry through spline approximation.
References
subquad
Comodo.subquad — Function
subquad(F::Vector{NgonFace{4,TF}},V::Vector{Point{ND,TV}},n::Int; method=:linear) where TF<:Integer where ND where TV <: Real
subquad(F::Vector{NgonFace{4,TF}},V::Vector{Point{ND,TV}},n::Int; method=:Catmull_Clark) where TF<:Integer where ND where TV <: RealRefines quadrangulations through splitting.
Description
The subquad function refines quad meshes iteratively. For each iteration each original input quad is split into 4 smaller quads to form the refined mesh. The following refinement methods are implemented:
method=:linear : This is the default method, and refines the quads in a simple linear manor through splitting. Each input edge simply obtains a new mid-edge node, and each face obtains a new central node.
method=:Catmull_Clark : This method features Catmull_Clark-subdivision [1]. Rather than linearly splitting edges and maintaining the original coordinates, as for the linear method, this method computes the new points in a special weighted sense such that the surface effectively approaches a bicubic B-spline surface. Hence this method both refines and smoothes the geometry through spline approximation.
References
_pushtoradius
Comodo._pushtoradius — Function
_pushtoradius(v::Point{N,T},r=1.0) where N where T <: Real
_pushtoradius(V::Vector{Point{N,T}},r=1.0) where N where T <: RealPushes points to a given radius
Description
This function pushes the input points to a distance r from the origin.
_pushtoradius!
Comodo._pushtoradius! — Function
_pushtoradius!(V::Vector{Point{N,T}},r=1.0) where N where T <: RealPushes points to a given radius
Description
This function is the same as pushtoradius_ but overwrites the input.
geosphere
Comodo.geosphere — Function
geosphere(n::Int,r::T; method=:linear) where T <: RealReturns a geodesic sphere triangulation
Description
This function returns 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 lengths. 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. Two methods are available, i.e. :linear (default) and :Loop (see also subtri). The former features simply linear splitting while the latter features the Loop method which may produce a smoother result.
hexbox
Comodo.hexbox — Function
hexbox(boxDim,boxEl)Returns hexahedral box mesh
Description
This function returns a hexahedral mesh for a 3D rectangular box domain.
con_face_edge
Comodo.con_face_edge — Function
con_face_edge(F,E_uni=nothing,indReverse=nothing)Returns the edges connected to each face.
Description
This function computes the face-edge connectivity. The input faces F (and optionally also the unique edges E_uni and reverse indices indReverse to map to the non-unique edges, see also gunique) are used to create a list of edges connected to each face. If F contains N faces then the output contains N such lists. For triangles the output contains 3 edges per faces, for quads 4 per face and so on.
con_edge_face
Comodo.con_edge_face — Function
con_edge_face(F,E_uni=nothing,indReverse=nothing)Returns the faces connected to each edge.
Description
This function computes the edge-face connectivity. The input faces F (and optionally also the unique edges E_uni and reverse indices indReverse to map to the non-unique edges, see also gunique) are used to create a list of faces connected to each edges. If E_uni contains N edges then the output contains N such lists. For non-boundary edges each edge should connect to 2 faces. Boundary edges connect to just 1 face.
con_face_face
Comodo.con_face_face — Function
con_face_face(F,E_uni=nothing,indReverse=nothing,con_E2F=nothing,con_F2E=nothing)Returns the edge-connected faces for each face.
Description
This function computes the face-face connectivity for each face. The input faces F are used to create a list of faces connected to each face by a shared edge. For non-boundary triangles for instance the output contains 3 edges per faces (which may be less for boundary triangles), and similarly non-boundary quads would each have 4 edge-connected faces. Additional optional inputs include: the unique edges E_uni, the reverse indices indReverse to map to the non-unique edges (see also gunique), as well as the edge-face con_E2F and face-edge con_F2E connectivity. These are all needed for computing the face-face connectivity and supplying them if already computed therefore saves time.
con_face_face_v
Comodo.con_face_face_v — Function
con_face_face_v(F,V=nothing,con_V2F=nothing)Returns the vertex-connected faces for each face.
Description
This function computes the face-face connectivity for each face. The input faces F are used to create a list of faces connected to each face by a shared vertex. Additional optional inputs include: the vertices V, and the vertex-face connectivity con_V2F. In terms of vertices only the number of vertices, i.e. length(V) is needed, if V is not provided it is assumed that length(V) corresponds to the largest index in F. The vertex-face connectivity if not supplied, will be computed by this function, hence computational time may be saved if it was already computed.
con_vertex_simplex
Comodo.con_vertex_simplex — Function
con_vertex_simplex(F,V=nothing)Returns how vertices connect to simplices
Description
This function computes the vertex-simplex connectivity for each vertex. The input simplices F are used to create a list of simplices connected to each vertex. Additional optional inputs include: the vertices V. In terms of vertices only the number of vertices, i.e. length(V) is needed, if V is not provided it is assumed that length(V) corresponds to the largest index in F.
con_vertex_face
Comodo.con_vertex_face — Function
con_vertex_face(F,V=nothing)Returns how vertices connect to faces
Description
This function is an alias of con_vertex_simplex, and computes the vertex-face connectivity for each vertex. The input faces F are used to create a list of faces connected to each vertex. Additional optional inputs include: the vertices V. In terms of vertices only the number of vertices, i.e. length(V) is needed, if V is not provided it is assumed that length(V) corresponds to the largest index in F.
con_vertex_edge
Comodo.con_vertex_edge — Function
con_vertex_edge(F,V=nothing)Returns how vertices connect to edges
Description
This function is an alias of con_vertex_simplex, and computes the vertex-edge connectivity for each vertex. The input edges E are used to create a list of edges connected to each vertex. Additional optional inputs include: the vertices V. In terms of vertices only the number of vertices, i.e. length(V) is needed, if V is not provided it is assumed that length(V) corresponds to the largest index in E.
con_edge_edge
Comodo.con_edge_edge — Function
con_edge_edge(E_uni,con_V2E=nothing)Returns the vertex-connected edges for each edge.
Description
This function computes the edge-edge connectivity for each edge. The input edges F are used to create a list of edges connected to each edge by a shared vertex. Additional optional inputs include: con_V2E (the vertex-edge connectivity), which is instead computed when not provided.
con_vertex_vertex_f
Comodo.con_vertex_vertex_f — Function
con_vertex_vertex_f(F,V=nothing,con_V2F=nothing)Returns the face-connected vertices for each vertex.
Description
This function computes the vertex-vertex connectivity for each vertex using the vertex connected faces. The input faces F are used to create a list of vertices connected to each vertex by a shared face. Additional optional inputs include: the vertices V and con_V2F (the vertex-face connectivity). In terms of vertices only the number of vertices, i.e. length(V) is needed, if V is not provided it is assumed that length(V) corresponds to the largest index in F. The vertex-face connectivity con_V2F is needed, hence is computed when not provided.
con_vertex_vertex
Comodo.con_vertex_vertex — Function
con_vertex_vertex(E,V=nothing,con_V2E=nothing)Returns the edge-connected vertices for each vertex.
Description
This function computes the vertex-vertex connectivity for each vertex using the vertex connected edges. The input edges E are used to create a list of vertices connected to each vertex by a shared edge. Additional optional inputs include: the vertices V and con_V2E (the vertex-edge connectivity). In terms of vertices only the number of vertices, i.e. length(V) is needed, if V is not provided it is assumed that length(V) corresponds to the largest index in E. The vertex-edge connectivity con_V2E is needed, hence is computed when not provided.
meshconnectivity
Comodo.meshconnectivity — Function
meshconnectivity(F::Vector{NgonFace{N,TF}},V::Vector{Point{ND,TV}}) where N where TF<:Integer where ND where TV<:RealReturns all mesh connectivity data
Description
This function returns the ConnectivitySet, i.e. all mesh connectivity data for the input mesh defined by the faces F and the vertices V. The ConnectivitySet contains the following connectivity descriptions:
- face-edge
- edge-face
- face-face
- face-face (wrt vertices)
- vertex-face
- vertex-edge
- edge-edge
- vertex-vertex
- vertex-vertex (wrt faces)
mergevertices
Comodo.mergevertices — Function
mergevertices(F::Vector{NgonFace{N,TF}},V::Vector{Point{ND,TV}}; roundVertices = true, numDigitsMerge=nothing) where N where TF<:Integer where ND where TV<:RealMerges points that coincide
Description
This function take the faces F and vertices V and merges points that are sufficiently similar. Once points are merged the indices in F are corrected for the new reduced point set.
smoothmesh_laplacian
Comodo.smoothmesh_laplacian — Function
smoothmesh_laplacian(F,V,con_V2V=nothing; n=1, λ=0.5)Description
This function implements weighted Laplacian mesh smoothing. At each iteration, this method replaces each point by an updated coordinate based on the mean coordinates of that point's Laplacian umbrella. The update features a lerp like weighting between the previous iterations coordinates and the mean coordinates. The code features Vs[q] = (1.0-λ).*Vs[q] .+ λ*mean(V[con_V2V[q]]) As can be seen, the weighting is controlled by the input parameter λ which is in the range (0,1). If λ=0 then no smoothing occurs. If λ=1 then pure Laplacian mean based smoothing occurs. For intermediate values a linear blending between the two occurs.
smoothmesh_hc
Comodo.smoothmesh_hc — Function
smoothmesh_hc(F::Vector{NgonFace{N,TF}},V::Vector{Point{ND,TV}}, n=1, α=0.1, β=0.5; con_V2V=nothing, tolDist=nothing, constrained_points=nothing) where N where TF<:Integer where ND where TV<:RealDescription
This function implements HC (Humphrey's Classes) smoothing [1]. This method uses Laplacian like smoothing but aims to compensate for shrinkage/swelling by also "pushing back" towards the original coordinates.
References
quadplate
Comodo.quadplate — Function
quadplate(plateDim,plateElem; orientation=:up)Returns a quad mesh for a plate
Description
This function creates a quadrilateral mesh (faces F and vertices V) for a plate. The dimensions in the x-, and y-direction are specified in the input vector plateDim, and the number of elements to use in each direction in the input vector plateElem.
quadsphere
Comodo.quadsphere — Function
quadsphere(r,pointSpacing)Returns a quadrangulated sphere
Description
This function creates a quadrilateral mesh (faces F and vertices V) for a sphere with a radius defined by the input r. The input pointSpacing defines desired approximate point spacing (which is most accurate for regions away from the original cube corners. The ouput consists of the faces F, the vertices V, and the underlying cube face boundary labels C.
simplex2vertexdata
Comodo.simplex2vertexdata — Function
simplex2vertexdata(F::Union{Vector{<: NgonFace},Vector{<: AbstractElement}},DF,V::Union{Nothing,Vector{Point{ND,TV}}}=nothing; con_V2F=nothing, weighting=:none) where ND where TV<:RealSamples element data on nodes
Description
This function converts the input data DF which is for the simplices (edges, faces, or elements) F, to the equivalent data for the nodes V. To compute this data on a particular node, the average for all simplices sharing the node is computed. The optional kwargs include con_V2F (the connectivity for vertices to simplices) which can be provided if already computed, and the weighting scheme desired, which can be set to :none (default) or :size. For the former a plain average of connected simplices is computed while for the latter the simplex sizes are taken into account e.g. for edges, faces, and elements, the averaging is weighted to the length, area, or volume of the simplex respectively.
vertex2simplexdata
Comodo.vertex2simplexdata — Function
vertex2simplexdata(F::Union{Vector{<: NgonFace},Vector{<: AbstractElement}}, DV)Samples node data on elements
Description
This function converts the input data DV which is for the nodes V, to the equivalent data for the simplices (edges, faces, or elements) F. To compute this data on a particular simplex, the average for all its nodes is computed.
simplexcenter
Comodo.simplexcenter — Function
simplexcenter(F,V::Vector{Point{ND,TV}}) where ND where TV<:RealComputs simplex centers
Description
This function computes centre of each simplex in F by taking the mean of the coordivertex2simplexdatanates as specified by V.
normalizevector
Comodo.normalizevector — Function
normalizevector(a::Union{Point{ND,TV},Vec{ND,TV}}) where ND where TV<:Real
normalizevector(A::Union{Vector{Point{ND,TV}},Vector{Vec{ND,TV}}}) where ND where TV<:RealNormalises vectors
Description
This function normalises the vector a or vector of vectors A such that each vector's lenght is 1.
circlepoints
Comodo.circlepoints — Function
circlepoints(r::T,n::Int; dir=:acw, pc = Point{3, Float64}(0.0, 0.0, 0.0)) where T <: Real
circlepoints(r::Tuple{T,T},n::Int; dir=:acw, pc = Point{3, Float64}(0.0, 0.0, 0.0)) where T <: Real
circlepoints(f::FunctionType,n::Int; dir=:acw, pc = Point{3, Float64}(0.0, 0.0, 0.0)) where {FunctionType <: Function}Returns points on circle
Description
This function returns n points on a circle. The radius for the circle is specified by the value of r. If instead r is a tuple containing two entries then these are assumed to represent the radius in the x and y direction respectively. Instead of the radius the user may also specify a function f which should specify the radius as a function of angle. The following optional keyword arguments exist:
dirsets the direction of the circle and is either:acworcwto select
an anti-clockwise or a clockwise direction. The default is the former.
pcdefined the circle centre. The default is simply the origin i.e.
Point{3, Float64}(0.0, 0.0, 0.0).
subquadsphere
Comodo.subquadsphere — Function
subquadsphere(n::Int,r::T) where T <: RealReturns a quadrangulated sphere
Description
This function creates a quadrilateral mesh (faces F and vertices V) for a sphere with a radius defined by the input r. The input n defines the density of sphere mesh. The quad mesh is constructed using subquad subdivision of a regular cube, whereby n sets the number of splitting iterations to use. Using n=0 therefore returns a cube. For subdivision the :Catmull_Clark subquad algorithm is used (except when n=1 where linear subdivision produces the same result) prior to pushing nodes to the sphere surface. The ouput consists of the faces F and the vertices V.
loflinear
Comodo.loftlinear — Function
loftlinear(V1,V2;num_steps=2,close_loop=true,face_type=:tri)Lofts surface between curves
Description
The loftlinear function spans a surface from input curve V1 to curve V2. The surface is formed by "lerping" curves from V1 to V2 in num_steps steps, and forming mesh faces between each curve. If close_loop==true then it is assumed the curves (and therefore the output surface mesh should be closed over, i.e. that a connection should be made between each curve end and start point. The user can request different face types for the output. The default is face_type=:tri which will form isoceles triangles (or equilateral triangles if the spacing is even) for a planar curve. The other face_type options supported are :quad (quadrilateral), and :tri_slash. For the latter, triangles are formed by slashing the quads.
Arguments:
V1::Vector: n-vectorV2::Vector: n-vector
grid2surf
Comodo.grid2surf — Function
grid2surf(V::Vector{Point{ND,TV}},num_steps; face_type=:quad, periodicity=(false,false), tri_dir=2) where ND where TV<:RealCreates surface from grid
Description
This function creates the faces F to form a closed surface for the input grid defined by the vector of points V. The grid is assumed to be structured i.e. that it is composed of num_steps point sets which each have point-to-point correspondence. Such a grid can represent a set of corresponding curves, or a set of columns of points for a Cartesian grid for instance. Optional inputs include the following:
face_type, which can be:quad(default),:tri,:tri_even,:backslash,
:forwardslash, or :quad2tri.
periodicity, which is of the typeTuple{Bool, Bool}. If
periodicity[1]==true it is assumed the grid is periodic in the first direction , i.e. that the grid should be closed in the first direction. If periodicity[2]==true it is assumed the grid is periodic in the second direction, i.e. that the grid should be closed in the second direction.
dirplot
Comodo.dirplot — Function
dirplot(ax,V::Vector{Point{ND,TV1}},U::Union{Vector{Point{ND,TV2}},Vector{Vec{ND,TV2}}}; color=:black, linewidth=3, scaleval=1.0, style=:from, kwargs...) where ND where TV1 <: Real where TV2 <: Real
dirplot(ax,V::Union{Point{ND,TV1},Vec{ND,TV1}},U::Union{Point{ND,TV2},Vec{ND,TV2}}; color=:black,linewidth=3,scaleval=1.0,style=:from, kwargs...) where ND where TV1 <: Real where TV2 <: RealPlots direction vectors
Description
This function visualises direction vectors. Rather than arrows the directions are visualised as lines. The line origins are defined by the point vector V while the line vectors are defined by the points (or vectors) in the vector U. The following optional keyword inputs are supported:
scaleval, this sets the scaling used. The default is 1.0 such that lengths match the lengths inUstyle, this sets how the direction is position. When using:from(default)
the vectors depart from the origin. If instead :to is used then the vectors arrive at the origin. Finally if :through is used the vector passes through the origin.
- Other optional keyword arguments supported are those for Makie's
wireframe
function, such as color and linewidth, the defaults for these are here set to :black and 3 respectively.
remove_unused_vertices
Comodo.remove_unused_vertices — Function
remove_unused_vertices(F::Union{Vector{<: NgonFace},Vector{<: AbstractElement}}, V::Vector{Point{ND,TV}}) where ND where TV<:Real
remove_unused_vertices(f::Union{NgonFace{N,TF}, AbstractElement{N,TF}}, V::Vector{Point{ND,TV}}) where N where ND where TF<:Integer where TV<:RealRemoves unused vertices
Description
This function removes unused points from the input mesh defined by the vector of faces F (or individual face f) and vector of vertices V. The output consists of the cleaned mesh given by Fc (or fc) and Vc, and also the "fixing indices" indFix. The latter can be used to fix indices that were for V previously to be the equivalent indices for the new vertex vector Vc, e.g. indFix[ind] would map the indices in ind to be mapped from being for V to being valid for Vc.
remove_unused_vertices!
Comodo.remove_unused_vertices! — Function
remove_unused_vertices!(F::Union{Vector{<: NgonFace},Vector{<: AbstractElement}},V::Vector{Point{ND,TV}}) where ND where TV<:RealRemoves unused vertices
Description
This function is the same as remove_unused_vertices, except that it is only for vectors of faces F and overwrites the input.
pointspacingmean
Comodo.pointspacingmean — Function
pointspacingmean(V::Vector{Point{3,Float64}{Float64}})
pointspacingmean(F::Array{NgonFace{N, Int}, 1},V::Vector{Point{3,Float64}{Float64}}) where N
pointspacingmean(f::NgonFace{N,TF},V::Vector{Point{ND,TV}}) where N where TF<:Integer where ND where TV<:RealComputes mean point spacing
Description
The pointspacingmean function computes the mean spacing between points. The input can be just the coordinate set V, a vector of Point{3,Float64} points, or also a set of edges E or faces F. If only V is provided it is assumed that V represents an ordered set of "adjacent" points, e.g. as for a curve. If a vector of edges E or a vector of faces F is also provided, then the average edge length is computed. If instead a set of facesF` is provided then edges are first computed after which the mean edge spacing is return.
pointspacingmin
Comodo.pointspacingmin — Function
pointspacingmin(V::Vector{Point{3,Float64}{Float64}})
pointspacingmin(F::Array{NgonFace{N, Int}, 1},V::Vector{Point{3,Float64}{Float64}}) where N
pointspacingmin(f::NgonFace{N,TF},V::Vector{Point{ND,TV}}) where N where TF<:Integer where ND where TV<:RealComputes minimum point spacing
Description
Similar to pointspacingmean but this function computes to minimum point spacing.
pointspacingmax
Comodo.pointspacingmax — Function
pointspacingmax(V::Vector{Point{3,Float64}{Float64}})
pointspacingmax(F::Array{NgonFace{N, Int}, 1},V::Vector{Point{3,Float64}{Float64}}) where N
pointspacingmax(f::NgonFace{N,TF},V::Vector{Point{ND,TV}}) where N where TF<:Integer where ND where TV<:Real
Computes maximum point spacingDescription
Similar to pointspacingmean but this function computes to maximum point spacing.
ray_triangle_intersect
Comodo.ray_triangle_intersect — Function
ray_triangle_intersect(F::Vector{TriangleFace{Int}},V,ray_origin,ray_vector; rayType = :ray, triSide = 1, tolEps = eps(Float64))
ray_triangle_intersect(f::TriangleFace{Int},V,ray_origin,ray_vector; rayType = :ray, triSide = 1, tolEps = eps(Float64))Description
This function can compute triangle-ray or triangle-line intersections through the use of the "Möller-Trumbore triangle-ray intersection algorithm" [1]. The required inputs are as follows:
F an single face or a vector of faces, e.g. Vector{TriangleFace{Int}} V The triangle vertices as a vector of points, i.e. Vector{Point{3, Float64}} ray_vector The ray vector which can be Vector{Point{3, Float64}} or Vec3{Float64}
The following optional input parameters can be provided: rayType = :ray (default) or :line. This defines whether the vector is treated as a ray (extends indefinitely) or as a line (finite length) triSide = 1 (default) or 0 or -1. When triSide=1 only the inward intersections are considered, e.g. when the ray or line enters the shape (ray/line is pointing against face normal) When triSide=-1 only the outward intersections are considered, e.g. when the ray or line exits the shape (ray/line is pointing along face normal) When triSide=0 both inward and outward intersections are considered. tolEps = eps(Float64) (default)
References
mesh_curvature_polynomial
Comodo.mesh_curvature_polynomial — Function
mesh_curvature_polynomial(F::Vector{TriangleFace{Int}},V::Vector{Point{3,Float64}{Float64}})
mesh_curvature_polynomial(M::GeometryBasics.Mesh)Description
This function computes the mesh curvature at each vertex for the input mesh defined by the face F and the vertices V. A local polynomial is fitted to each point's "Laplacian umbrella" (point neighbourhood), and the curvature of this fitted form is derived. Instead of the mesh faces and vertices one may instead specify the GeometryBasics.Mesh M as the input.
The reference below [1] provides more detail on the algorithm. In addition, this implementation was created with the help of this helpful document, which features a nice overview of the theory/steps involved in this algorithm.
References
separate_vertices
Comodo.separate_vertices — Function
separate_vertices(F::Array{NgonFace{N, Int}, 1},V::Array{Point{M, T}, 1}) where N where M where T<:Real
separate_vertices(M::GeometryBasics.Mesh)This function takes the input mesh defined by the faces F and vertices V and separates any shared vertices. It does this by giving each face its own set of unshared vertices. Note that any unused points are not returned in the output point array Vn. Indices for the mapping are not created here but can simply be obtained using reduce(vcat,F).
evenly_sample
Comodo.evenly_sample — Function
evenly_sample(V::Vector{Point{ND,TV}}, n::Int; rtol = 1e-8, niter = 1) where ND where TV<:RealEvenly samples curves.
Description
This function aims to evenly resample the input curve defined by the ND points V using n points. The function returns the resampled points as well as the spline interpolator S used. The output points can also be retriebed by using: S.(range(0.0, 1.0, n)). Note that the even sampling is defined in terms of the curve length for a 4th order natural B-spline that interpolates the input data. Hence if significant curvature exists for the B-spline between two adjacent data points then the spacing between points in the output may be non-uniform (despite the along B-spline distance being uniform).
invert_faces
Comodo.invert_faces — Function
invert_faces(F::Vector{NgonFace{N, TF}, 1}) where N where TF<:IntegerFlips face orientations.
Description
This function inverts the faces in F, such that the face normal will be flipped, by reversing the node order for each face.
kabsch_rot
Comodo.kabsch_rot — Function
R = kabsch_rot(V1::Array{Point{N, T}, 1},V2::Array{Point{N, TT}, 1}) where N where T<:Real where TT<:RealDescription
Computes the rotation tensor R to rotate the points in V1 to best match the points in V2.
Reference
Wolfgang Kabsch, A solution for the best rotation to relate two sets of vectors, Acta Crystallographica Section A, vol. 32, no. 5, pp. 922-923, 1976, doi: 10.1107/S0567739476001873 https://en.wikipedia.org/wiki/Kabsch_algorithm
sweeploft
Comodo.sweeploft — Function
F,V = sweeploft(Vc,V1,V2; face_type=:quad, num_twist = 0, close_loop=true)Description
This function implements swept lofting. The start curve V1 is pulled along the guide curve Vc while also gradually (linearly) morphing into the end curve V2. The optional parameter face_type (default :quad) defines the type of mesh faces uses. The same face types as loftlinear and extrudecurve are supported, i.e. :quad, :tri_slash, tri, or quad2tri. The optional parameter num_twist (default is 0) can be used to add an integer number (negative or positive) of full twists to the loft. Finally the optional parameter close_loop (default is true) determines if the section curves are deemed closed or open ended.
revolvecurve
Comodo.revolvecurve — Function
revolvecurve(Vc::Vector{Point{ND,TV}}; extent = 2.0*π, direction=:positive, n=Vec{3, Float64}(0.0,0.0,1.0),num_steps=nothing,close_loop=true,face_type=:quad) where ND where TV<:RealRevolves curves to build surfaces
Description
This function rotates the curve Vc by the angle extent, in the direction defined by direction (:positive, :negative, :both), around the vector n, to build the output mesh defined by the faces F and vertices V.
batman
Comodo.batman — Function
batman(n::Int)Description
The batman function creates points on the curve for the Batman logo. The curve is useful for testing surface meshing algorithms since it contains sharp transitions and pointy features. The user requests n points on the curve. The default uses the option stepwise=true, which means curve segments are sampled separately and hence all sharp features and corners are captured. In this case the actual number of points on the curve can deviate from n (be a bit higher), as each curve segment features at least two points. If instead stepwise=false is used then the function forces exactly n points. In this case the full closed curve is resampled as a whole, which may mean "corners are cut". The second optional input is the direction of the curve, i.e. if it is clockwise, dir=:cw or anti-clockwise dir=:acw (default). The implementation is based on a "parameterised Batman equation" 1. However, instead of the equation, here use is made of Bezier spline segments that were fitted to the equation. This also improves the evenly spaced parameterisation presented here. In addition, here the curve is here centered around [0,0,0], and the width was scaled to be 2.
References
- https://www.desmos.com/calculator/ajnzwedvql
tridisc
Comodo.tridisc — Function
tridisc(r=1.0,n=0; ngon=6, method = :linear, orientation=:up)Description
Generates the faces F and vertices V for a triangulated disc (circle). The algorithm starts with a triangulated hexagon (obtained if n=0) and uses iterative subtriangulation, and uses iterative subdivision (and pushing of boundary points to circular boundary) to obtain the final mesh. The subdivision method is an optional input, and is either :Loop (default) or :linear. Lastly the optional input orientation, which can be :up or :down sets the face normal direction.
regiontrimesh
Comodo.regiontrimesh — Function
regiontrimesh(VT,R,P)Description
Generates a multi-region triangle mesh for the input regions. The boundary curves for all regions are contained in the tuple VT. Each region to be meshed is next defined using a tuple R containing indices into the curve tuple VT. If an entry in R contains only one index then the entire curve domain is meshed. If R contains multiple indices then the first index is assumed to be for the outer boundary curve, while all subsequent indices are for boundaries defining holes in this region.
scalesimplex
Comodo.scalesimplex — Function
scalesimplex(F,V,s)Scales faces (or general simplices) wrt their centre.
Description
This function scales each simplex (e.g. a face) wrt their centre (mean of coordinates). This function is useful in generating lattice structures from elements as well as to create visualisations whereby "looking into" the mesh is needed.
subcurve
Comodo.subcurve — Function
subcurve(V,n)Adds n points between each curve point.
Description
This function adds n points between each current point on the curve V.
dualclad
Comodo.dualclad — Function
dualclad(F::Vector{NgonFace{N, TF}},V::Vector{Point{ND,TV}},s::T; connectivity=:face) where N where TF<:Integer where ND where TV<:Real where T<:RealReturns a surface conforming dual lattice
Description
tet2hex
Comodo.tet2hex — Function
tet2hex(E::Vector{Tet4{T}},V::Vector{Point{ND,TV}}) where T<:Integer where ND where TV<:RealConverts tetrahedra to hexahedra
Description
This function converts the input tetrahedra defined by the element set E and the vertex set V to a set of hexahedral elements Eh with vertices Vh. The conversion involves a splitting of each tetrahedron into 4 hexahedra.
element2faces
Comodo.element2faces — Function
element2faces(E::Vector{<: AbstractElement{N, T}}) where N where TReturns element faces
Description
This function computes the faces for the input elements defined by E. The elements should be Vectors consisting of Tet4, Hex8 elements.
subhex
Comodo.subhex — Function
subhex(E::Vector{Hex8{T}},V::Vector{Point{ND,TV}},n::Int; direction=0) where T<:Integer where ND where TV<:RealSplits hexahedral elements
Description
This function splits the hexahedral elements defined by the elements E and vertices V. Splitting is done n times as requested. By default the splitting occurs in all direction (corresponding to the default direction=0). If instead direction is set to 1, 2, or 3, then the splitting only occur in the first, second or third local element direction respectively. Note that this direction depends on node order used. For a hexahedron where by nodes 1:4 are for the bottom, and nodes 5:8 are for the top of the element then the directions 1, 2, and 3 correspond to the x-, y-, and z-direction respectively.
rhombicdodecahedron
Comodo.rhombicdodecahedron — Function
rhombicdodecahedron(r = 1.0)Creates mesh for rhombicdodecahedron
Description
This function creates the faces F and vertices V for a rhombicdodecahedron. The size of the shape is set by the width w in the xy-plane.
tri2quad
Comodo.tri2quad — Function
tri2quad(F,V; method=:split)Converts triangles to quads
Description
This function converts the input triangular mesh, defined by the faces F and vertices V, to a quadrangulation. The method for this conversion is set using the attribute method which can be set to :split, splitting each triangle into 3 quads by introducing a new central node, or :rhombic. whereby each triangle edge is used to construct a rhombic quadrilateral face.
tetgenmesh
Comodo.tetgenmesh — Function
tetgenmesh(F::Array{NgonFace{N,TF}, 1},V::Vector{Point{3,TV}}; facetmarkerlist=nothing, V_regions=nothing,region_vol=nothing,V_holes=nothing,stringOpt="paAqYQ") where N where TF<:Integer where TV<:RealCreates a tetrahedral mesh
Description
This function uses the TetGen.jl library to mesh the input geometry defined by the faces F and the vertices V using tetrahedral elements. Several optional input parameters are available:
facetmarkerlist, a vector of integers with the same length asFand defines a face label for each face.V_regions, a vector of points inside regions which require tetrahedral meshing.region_vol, a vector of scalar values to denote the desired tetrahedral volume for each region.V_holes, a vector of points inside holes (voids) that should remain empty.stringOpt, the TetGen command string to use. See also the TetGen documentation.
surfacevolume
Comodo.surfacevolume — Function
surfacevolume(F::Vector{NgonFace{N,TF}},V::Vector{Point{ND,TV}}) where N where TF<:Integer where ND where TV<:RealComputes closed surface volume
Description
This function computes the volume of a closed surface defined by the faces F and the vertices V.
tetvolume
Comodo.tetvolume — Function
tetvolume(E::Vector{Tet4{T}},V::Vector{Point{ND,TV}}) where T<:Integer where ND where TV<:RealComputes tetrahedral volumes
Description
This function computes the volume for each tetrahedron defined by the input E, a vector of Tet4 elements, and V the point coordinates.
extrudefaces
Comodo.extrudefaces — Function
extrudefaces(F::Vector{NgonFace{NF,TF}},V::Vector{Point{ND,TV}}; extent=1.0, direction=:positive, num_steps=2, N::Union{Vector{Point{ND,TN}},Vector{Vec{ND, TN}},Nothing}=nothing) where NF where TF<:Integer where ND where TV<:Real where TN<:RealExtrudes/thickens faces to form elements
Description
The inputs surface mesh, defined by the faces F and vertices V is extruded to create volumetric elements. Quadrilateral and triangular input faces are supported. These extrude into hexahedral and pentahedral elements respectively. The following input parameters are defined:
extent<:Real(default = 1.0) the length of the extrusiondirectionis a symbol that is either:positive(default),:negative, or:both.NThe extrusion vectors. The default is nothing in which case the local
vertex normals are used.
num_steps(default is 2) is the number of nodes in the extrude direction, the
number of elements in the extrude direction is therefore num_steps-1.
filletcurve
Comodo.filletcurve — Function
filletcurve(V::Vector{Point{NV,TV}}; rMax::Union{Vector{T},T,Nothing}=nothing, constrain_method = :max, n=25, close_loop = false, eps_level = 1e-6) where TV<:Real where NV where T<:RealFillets/rounds curves
Description
The function takes in a curve defined by the points V and applies filleting (or rounding) to each "corner" (i.e. a point between two neighbouring points). The maximum radius rMax is used as the largest possible radius to use. If this, radius is not possible (e.g. if input points are too close), then a lower Radius is used.
squircle
Comodo.squircle — Function
squircle(r::T,n::Int,τ=0.5; atol=1e-6, dir=:acw) where T <: RealCreates the squircle curve
Description
This function returns n points on a squircle. The squircle curve is defined using the radius r, and the parameter τ. The latter controls the morphing between a circle (τ=0) and square (τ=1).
circlerange
Comodo.circlerange — Function
circlerange(n::Int; dir=:acw, deg=false)Creates circular angles
Description
This function returns n angles for an even circular distribution of points. The optional input dir can be set to :acw (default) resulting in an anti-clockwise set of angles, and can be set to :cw for a clockwise set of angles. Angles are returned in radians since deg is false by default. Using deg=true results in angles in degrees.
edgefaceangles
Comodo.edgefaceangles — Function
edgefaceangles(F::Vector{NgonFace{NF,TF}},V::Vector{Point{ND,TV}}; deg=false) where NF where TF<:Integer where ND where TV<:RealComputed angles between faces
Description
This function computes the angle between two faces for each unique edge in the mesh specified by F and the vertices V. If the input mesh consists of n unique edges then the output features n angles. For boundary edges, where no pair of faces exists, the angle returned is NaN. The default behaviour results in angles being computed in radians. However by specifying deg=true the user can request degrees instead. Finally two additional outputs are created, namely the unique edge vector E_uni as well as the edge-to-face connectivity vector ,con_E2F.
faceanglesegment
Comodo.faceanglesegment — Function
faceanglesegment(F::Vector{NgonFace{NF,TF}},V::Vector{Point{ND,TV}}; deg=false, angleThreshold = π/8, indStart = 1) where NF where TF<:Integer where ND where TV<:RealSegments surfaces using face angles
Description
This function takes in a surface mesh defined by the faces F and the vertices V, and segments the surface mesh based on face angles. The output consists of a "feature label" vector G (a Vector{Int}, with the same length of F) whereby adjacent faces whosee angle is smaller or equal to the angleThreshold (default is π/8) receive the same label. Hence this function allows one to find all faces with a similar orientation, for instance all top or side faces of some mesh. The function uses radians by default. However, buy specifying the optional parameter deg=true the user request that angles and the angleThreshold are in degrees.
eulerchar
Comodo.eulerchar — Function
eulerchar(F,V=nothing; E=nothing)Computes the Euler characteristic
Description
This function computes the Euler characteristic for the input surface defined by the faces F and vertices V. The edges E are on optional input. The Euler characteristic is defined as: X = nV-nE-nF , where nV, nE, and nF define the number of surface vertices, edges, and faces respectively. It is assumed all inputs are set of unique entities, e.g. no vertices, edges, or faces occur multiple times.
rhombicdodecahedronfoam
Comodo.rhombicdodecahedronfoam — Function
rhombicdodecahedronfoam(w::T,n::Union{Tuple{Vararg{Int, 3}}, Array{Int, 3}}; merge = true, orientation = :align) where T<:RealCreates a rhombicdodecahedron foam
Description
This function creates a rhombicdodecahedron foam structure with a desired number of cells in each direction. The input is the cell width w and a 1-by-3 tuple n defining the number of cells in each direction. The output consists of the set of rhombic dodecahedron elements E and their vertex coordinates V.
truncatedoctahedron
Comodo.truncatedoctahedron — Function
truncatedoctahedron(w=1.0)Creates a truncated octahedron
Description
This function creates a truncated octahedron. The input cell width w is used to define the cell faces F and vertices V.
kelvinfoam
Comodo.kelvinfoam — Function
kelvinfoam(w::T,n::Union{Tuple{Vararg{Int, 3}}, Array{Int, 3}}; merge = true) where T<:RealCreates a Kelvin foam
Description
This function creates a Kelvin foam structure with a desired number of cells in each direction. The input is the cell width w and a 1-by-3 tuple n defining the number of cells in each direction. The output consists of the set of truncated octahedron elements E and their vertex coordinates V.
minp
Comodo.minp — Function
minp(V) where N where T <:RealReturns minimum coordinates
Description
This function computes the minimum coordinates for all points. Points can be N-dimensional and the output is another point of the same dimensionality but with the lowest coordinate value for each direction.
maxp
Comodo.maxp — Function
maxp(V) where N where T <:RealReturns maximum coordinates
Description
This function computes the maximum coordinates for all points. Points can be N-dimensional and the output is another point of the same dimensionality but with the highest coordinate value for each direction.
ntrapezohedron
Comodo.ntrapezohedron — Function
ntrapezohedron(n,r=1.0)Constructs an n-trapezohedron
Description
This function creates the faces F and vertices V for an n-trapezohedron.
The implementation is based on the equations presented here: https://mathworld.wolfram.com/Trapezohedron.html
spacing2numvertices
Comodo.spacing2numvertices — Function
spacing2numvertices(F::Vector{TriangleFace{TF}},V::Vector{Point{ND,TV}},pointSpacing::TP) where TF<:Integer where ND where TV<:Real where TP<:RealPoint numbers from spacing
Description
This function helps to determine what number of vertices to resample a surface with to obtain a desired point spacing. The input consists of in initial surface , defined by the faces F and the vertices V, and also the desired point spacing pointSpacing. Next the function uses the surface Euler characteristic as well as knowledge of face area and point spacing changes for homogeneous face splitting (e.g. via subtri), to determine the theoretical number of pointsNV` a resampled surface should have to present with the desired point spacing.
joingeom
Comodo.joingeom — Function
joingeom(G...)Joins geometry
Description
This function joins geometry defined for instance by multiple face and vertex sets into one such set. All geometry such be of the same type such that they can be joined. The input can for instance be n-sets of faces (or elements) and vertices e.g. appearing as inpus as: F1,V1,F2,V2,...,FN,VN.
quadbox
Comodo.quadbox — Function
quadbox(boxDim,boxEl)Creates quadrilateral box mesh
Description
This function uses the dimensions defined in boxDim, and the number of elements listed for each direction in boxEl to create a quadrilateral mesh for a box. The output consists of the faces F, the vertices V, and a face labelling C (for the 6 sides of the box).
tribox
Comodo.tribox — Function
tribox(boxDim,pointSpacing)Creates triangulated box mesh
Description
This function uses the dimensions defined in boxDim, and the desired point spacing defined by pointSpacing, to create a triangulated mesh for a box. The output consists of the faces F, the vertices V, and a face labelling C (for the 6 sides of the box).
tetbox
Comodo.tetbox — Function
tetbox(boxDim,pointSpacing; stringOpt = "paAqYQ",region_vol=nothing)Creates tetrahedral box mesh
Description
This function uses the dimensions defined in boxDim, and the desired point spacing defined by pointSpacing, to create a tetrahedral mesh for a box. The output consists of the elements E, the vertices V, the boundary faces Fb, and the boundary face labelling Cb (for the 6 sides of the box).
pad3
Comodo.pad3 — Function
pad3(A::Array{T,3}; padAmount = 1, padValue = T(0.0)) where T<:RealPads 3D array
Description
This function pads the 3D input array A by the amount padAmount and with the value padValue. The output is an array that is 2*padAmount larger in size direction.
getisosurface
Comodo.getisosurface — Function
getisosurface(A; level=0.0, cap=false, padValue=nothing, x::Union{AbstractVector{T},Nothing}=nothing, y::Union{AbstractVector{T},Nothing}, z::Union{AbstractVector{T},Nothing}) where T<:RealConstructs isosurface geometry
Description
This function creates the triangular faces F and vertices V for an isosurface in the 3D image A of the level specified by level.
stepfunc
Comodo.stepfunc — Function
stepfunc(type)Returns a step function
Description
This function returns a step function (such as smoothstep functions [1]) to move from a level a to b using the function type specified by type. I.e. f = stepfunc(type) can be used as: y = f(a,b,t) The functions are constrained such that the output is a if t<=0.0 and the output is b when t>=1.0. Each function uses the following definition: (1.0 - f(t)) * a + f(t) * b Where f(t) depends on the function type requested. The following types are supported: :linear, this is a simple linear mapping (lerp) from a to b :Perlin, the Perlin smooth step function 6t⁵-15t⁴+10t³ :smoothstep, 6t²-2t³ :cosine, 2-cos(tπ)/2 The default is :linear
References
- https://en.wikipedia.org/wiki/Smoothstep
perlin_noise
Comodo.perlin_noise — Function
perlin_noise(size_grid, sampleFactor, type=:Perlin)Returns Perlin noise array
Description
This function returns a 2D image containing Perlin noise [1]. The grid size is defined by size_grid. The sampleFactor defines the number of pixels to use for each grid cell. The output is a Matrix{Float64} with the size (size_grid .- 1) .* sampleFactor. The type parameter dictates the type of "fade" function to use (see also: stepfunc), and the default is :Perlin.
References
- https://en.wikipedia.org/wiki/Perlin_noise
removepoints
Comodo.removepoints — Function
removepoints(V,indRemove)Removes listed points
Description
This function removes the points indRemove from the point vector V. The output contains a vector lacking these points, as well as indFix, a vector of indices that can be used to update indices from before the point removal to equivalent indices after point removal.
inpolygon
Comodo.inpolygon — Function
inpolygon(p::Point{M,T}, V::Vector{Point{N,T}}; atol = sqrt(eps(T))) where N where M where T<:Real
inpolygon(P::Vector{Point{M,T}}, V::Vector{Point{N,T}}; atol = sqrt(eps(T))) where N where M where T<:RealFinds points in/on/out of polygon
Description
This function is an improved version of the algorithm proposed by Hao et al. [1] for determining if the input points P are inside the polygon defined by the input V. For a single point the output is a single integer which is:
- -1 if the point is computed to be outside of the polygon
- 0 if the point is computed to be on the boundary of the polygon
- 1 if the point is computed to be inside the boundary
If the input is instead a vector of points then the output consists of a corresponding vector of such integers. This implementation differs from [1] in terms of the use of atol for approximate equivalence. This helps in more robust labelling of "on polygon" points.
References
- https://doi.org/10.3390/sym10100477
_indexPair2sortedEdge
Comodo._indexPair2sortedEdge — Function
_indexPair2sortedEdge(i,j)Created sorted edge from indices
Description
This function takes in a pair of integers i and j and converts it to a LineFace, i.e. a GeometryBasics edge. In addition the indices are sorted.
elementEdges
Comodo.elementEdges — Function
elementEdges(E::Vector{<: AbstractElement{N, T}}) where N where TReturns element edges
Description
This function takes in the element vector E (e.g. containing Tet4, Penta6 entries) and returns a vector of edges.
tet4_tet10
Comodo.tet4_tet10 — Function
tet4_tet10(E,V)Converts linear to quadratic tetrahedra
Description
This function converts the input linear 4-noded tetrahedral elements, defined by the element vector E and vertices V, to 10 noded quadratic tetrahedral elements, defined by the output element vector E_tet10 and vertices V_tet10.
tet4_tet15
Comodo.tet4_tet15 — Function
tet4_tet10(E,V)Converts linear to quadratic tetrahedra
Description
This function converts the input linear 4-noded tetrahedral elements, defined by the element vector E and vertices V, to 15 noded quadratic tetrahedral elements, defined by the output element vector E_tet15 and vertices V_tet15.
penta6_penta15
Comodo.penta6_penta15 — Function
penta6_penta15(E,V)Converts linear to quadratic pentahedra
Description
This function converts the input linear 6-noded pentahedral elements, defined by the element vector E and vertices V, to 15 noded quadratic pentahedral elements, defined by the output element vector E_penta15 and vertices V_penta15.
findindexin
Comodo.findindexin — Function
findindexin(a, b::AbstractArray; missingIndex=0)Finds indices from one to another indexable
Description
This function is the same as Julia's indexin. However here by default the "index" returned for a missing entry is 0 rather than nothing. This means that the output is by default a Vector{Int64} rather than a Vector{Union{Nothing, Int64}}. To return something other than 0, the user can set the optional attribute missingIndex.
hexagonline
Comodo.hexagonline — Function
hexagonline(r::T,n::Int; type=:ufdf) where T<:RealReturns hexagon mesh edge lines
Description
This function returns a honeycomb mesh edge lines e.g. a connected set of edges.
hexagongrid
Comodo.hexagongrid — Function
hexagongrid(r::T,n::Tuple{TI, TI}; weave=0.0) where T<:Real where TI <:IntegerReturns honeycomb vertex grid
Description
This function returns the vertices for a n[1] by n[2] honeycomb grid, where the cells have a radius r.
hexagonmesh
Comodo.hexagonmesh — Function
hexagonmesh(r::T,nf::Tuple{Int, Int}; weave=0.0) where T<:RealReturns a hexagon mesh
Description
This function returns the faces F and vertices V for a hexagon mesh.The hexagon cells are defined with a radius r and the tuple nf defines the number of cells in the x- and y-direction.
fromtomesh!
Comodo.fromtomesh! — Function
fromtomesh!(F1::Vector{NgonFace{NF,TF}},V1::Vector{Point{ND,TV}},V2::Vector{Point{ND,TV}},num_steps; correspondence=:match) where NF where TF<:Integer where ND where TV<:RealCreates mesh to points
Description
This function return volumetric elements formed by extruding the faces F1 from their coordinates in V1 up to the coordinates in V2. The user can specify the number of node layers (1 + number of element layers) used with the input num_steps. The optional argument correspondence can be set to :match (default) or :faces. For the former the points in V1 and V2 are assumed to fully correspond, while for the latter it is assumed the points in V2 correspond to a subset in V1, namely with the consecutive point indices in F2. For fromtomesh! the ouput is En the elements (Quadrilateral faces are extruded to form hexahedral elements, and Triangular faces are extruded to form pentahedral elements),a and the new points are appended to the input vector V1.
fromtomesh
Comodo.fromtomesh — Function
fromtomesh(F1::Vector{NgonFace{NF,TF}},V1::Vector{Point{ND,TV}},V2::Vector{Point{ND,TV}},num_steps; correspondence=:match) where NF where TF<:Integer where ND where TV<:RealCreates mesh to points
Description
This function is the same as fromtomesh!, however the output consists of the elements En and the total point set Vn(i.e. the input vector V1 is not perturbed).
vectorpair_angle
Comodo.vectorpair_angle — Function
vectorpair_angle(v1,v2,n=nothing; deg = false)Returns angle between vector pair
Description
This function computes the angle between the two vectors v1 and v2. The optional argument n (default is nothign) is a vector that should define the normal direction for the vector pair. The optional argument deg sets wether the angle is returned in degrees (if deg=true) or radians.
triangulateboundary
Comodo.triangulateboundary — Function
triangulateboundary(V, ind, N, anglethreshold; deg = false, close_loop=false)Forms triangles on boundary
Description
This function computes angles on the curve (which could be a mesh boundary) defined by the points V[ind], where V is a vector of points and ind a vector of point indices. The vector N contains the normal direction for each point in V[ind]. If at a given point the adjacent curve segments form an angle that is smaller than angleThreshold then a triangular face is formed for these segments. This function can hence be used to partially cure a jagged boundary by closing sharp inward pointing regions with triangles. The optional argument deg (default is false) sets wether the threshold is set in degrees (if deg==true) or radians (default). The optional argument close_loop set wether the curve should be seen as closed.
faceinteriorpoint
Comodo.faceinteriorpoint — Function
faceinteriorpoint(F,V, indFace; w=0.5)Returns interior point for given face
Description
This function takes in the faces F, the points V, and a face index indFace, and returns a point that is between the face center and the opposing side of the surface. The default behaviour, when the optional argument w=0.5, returns a point mid-way between the face centre and the opposite side. If w=0.0 is used the face centre is returned while with w=1.0 the opposing point is returned.
hexsphere
Comodo.hexsphere — Function
hexsphere(r=1.0,pointSpacing=r/10.0; f=0.75, nSmooth=5)Creates hexahedral sphere mesh
Description
This function returns a hexahedral mesh for a sphere. The inputs include the radius r, and the point spacing pointSpacing. The optional inputs include the factor f which sets where width of the central cube, which is defined as: f/sqrt(3.0)*2.0*r. The output features hexahedral elements E and the vertices V.
hexspherehollow
Comodo.hexspherehollow — Function
hexspherehollow(rOut,rIn,pointSpacing; numSteps=nothing)Creates hollow hexahedral sphere mesh
Description
This function returns a hexahedral mesh for a hollow sphere. The inputs include the outer radius rOut, the inner radius rIn, and the point spacing pointSpacing. The optional inputs include the number of vertex steps to use to go from the inner to the outer surface. The output features hexahedral elements E and the vertices V.
circumcircle
Comodo.circumcircle — Function
circumcircle(P)
circumcircle(f::TriangleFace{TF}, V::Vector{Point{3,TV}}) where TF<:Integer where TV<:Real
circumcircle(F::Vector{TriangleFace{TF}}, V::Vector{Point{3,TV}}) where TF<:Integer where TV<:RealReturns circumcircle parameters
Description
This function returns the radii and centres for circumcircles for the triangles defined by the input.
Syntax: circumcircle(P) Pis a point vector containing a triplet of points for a single triangle.
Syntax: circumcircle(f, V) fis a single TraingleFace and V a point vector defining the triangle vertices.
Syntax: circumcircle(F, V) Fis a vector TraingleFace entries and V a point vector defining the triangle set vertices.
incircle
Comodo.incircle — Function
incircle(P)
incircle(f::TriangleFace{TF}, V::Vector{Point{3,TV}}) where TF<:Integer where TV<:Real
incircle(F::Vector{TriangleFace{TF}}, V::Vector{Point{3,TV}}) where TF<:Integer where TV<:RealReturns incircle parameters
Description
This function returns the radii and centres for incircles for the triangles defined by the input.
Syntax: incircle(P) Pis a point vector containing a triplet of points for a single triangle.
Syntax: incircle(f, V) fis a single TraingleFace and V a point vector defining the triangle vertices.
Syntax: incircle(F, V) Fis a vector TraingleFace entries and V a point vector defining the triangle set vertices.
meshplot!
Comodo.meshplot! — Function
meshplot!(ax,F::Vector{NgonFace{N,Int}},V::Vector{Point{NV,TV}}; stroke_depth_shift=-0.01f0, color=:white, strokewidth=0.5f0, shading=true, strokecolor=:black, kwargs...) where N where NV where TV<:Real
meshplot!(ax,M::GeometryBasics.Mesh; stroke_depth_shift=-0.01f0, color=:white, strokewidth=0.5f0, shading=true, strokecolor=:black, kwargs...)Visualises a surface mesh
Description
This function visualises the mesh defined by either the faces F and vertices V or the GeometryBasics.Mesh M. The function uses Makie.poly! "under the hood" but features defaults that are common for mesh visualisation and geometry processing. Optional inputs include the full set for poly.
edgeplot!
Comodo.edgeplot! — Function
edgeplot!(ax,E::Vector{LineFace{Int}},V::Vector{Point{N,TV}}; depth_shift=-0.015f0, color=:black, linewidth=0.5f0, kwargs...) where N where TV<:Real
edgeplot!(ax,M::GeometryBasics.Mesh; depth_shift=-0.015f0, color=:black, linewidth=1.0f0, kwargs...)Visualises edges
Description
This function visualises the edges defined by either the edges E and vertices V or the GeometryBasics.Mesh M. The function uses Makie.wireframe! "under the hood" but features defaults that are common for mesh edge visualisation and geometry processing. Optional inputs include the full set for wireframe.
meshdual
Comodo.meshdual — Function
meshdual(F,V)Computes the mesh dual
Description
This function derives the dual mesh for the input faces F and vertices V.
delaunay2D
Comodo.delaunay2D — Function
delaunay2D(V::Vector{Point{ND,TV}}) where ND where TV<:RealReturns 2D Delaunay triangulation
Description
This function returns the faces F and vertices V for the 2D Delaunay triangulation of the input points V. Note that the 3rd dimension is ignored hence the point set is assumed to be planar in the XY-plane. The default behaviour results in a unconstrained Delaunay triangulation. However additional constraints can be specified to define a constrained Delaunay triangulation.
erodeboundary!
Comodo.erodeboundary! — Function
erodeboundary!(F::Vector{NgonFace{NF,TF}},V::Vector{Point{NV,TV}},α) where NF where TF<:Integer where NV where TV<:RealErodes the mesh boundary
Description
This function takes the input mesh defined by the faces F and the vertices V and "erodes it" at the boundary, in other words boundary triangles are removed based on a certain criteria. The default behaviour is to use the method :circumcircle. For this method boundary triangles are removed if their circumcicle exceed the value α. This means that when :circumcircle is used (and the input represents a Delaunay triangulation) that the alpha complex is returned. Another supported method is :edgelength, where instead the boundary edge length is used as the criteria to remove triangles. This function manipulates both inputs and removes any points that are no longer part of the triangulation.
erodetriangulation!
Comodo.erodetriangulation! — Function
erodetriangulation!(F::Vector{TriangleFace{TF}},V::Vector{Point{NV,TV}}, α::TA; method=:circumcircle, domain=:boundary) where TF<:Integer where NV where TV<:Real where TA<:RealErodes the input mesh
Description
This function takes the input mesh defined by the faces F and the vertices V and "erodes it" either throughout or only at the boundary (equivalent to erodeboundary). Triangles are removed based on a certain criteria. The default behaviour is to use the method :circumcircle. For this method triangles are removed if their circumcicle exceed the value α. Another supported method is :edgelength, where instead the edge length is used as the criteria to remove triangles. This function manipulates both inputs and removes any points that are no longer part of the triangulation.
simplicialcomplex
Comodo.simplicialcomplex — Function
erodetriangulation!(F::Vector{TriangleFace{TF}},V::Vector{Point{NV,TV}}, α::TA; method=:circumcircle, domain=:boundary) where TF<:Integer where NV where TV<:Real where TA<:RealCreates simplicial complex triangulation
Description
This function takes the input point vector V and constructs a Delaunay triangulation, and erodes it using the method and domain specified. See also: erodetriangulation.
alphacomplex
Comodo.alphacomplex — Function
alphacomplex(V::Vector{Point{NV,TV}},α::TA) where NV where TV<:Real where TA<:Real
Returns point set alphacomplex
Description
This function takes the input point vector V and constructs the alpha complex. In other words it creates a Delaunay triangulation and erodes it based on the α complex criterion (circumcicle radii should be smaller than α). See also: simplicialcomplex, erodetriangulation!.
indices_faces_at_boundary_edges
Comodo.indices_faces_at_boundary_edges — Function
indices_faces_at_boundary_edges(F::Vector{NgonFace{NF,TF}}) where NF where TF<:IntegerReturns perimeter face indices
Description
This function returns the indices of the faces that are at the boundary for the input surface mesh defined by the faces F.
rectangle
Comodo.rectangle — Function
rectangle(w::T, h::T; orientation=:up) where T<:RealReturns rectangle face and vertices
Description
This function returns a face f and a vector of corner points for a rectangle. The user can specify the widht w and the height h. The direction (point order) can be defined by optional argument dir which can be :acw (default) or :cw.
rectanglepoints
Comodo.rectanglepoints — Function
rectanglepoints(w::T, h=w; dir=:acw) where T<:Real
rectanglepoints(w::T, h::T, pointSpacing::T; dir=:acw) where T<:RealReturns rectangle boundary points
Description
This function returns a vector of points on the boundary of a rectangle. The user can specify the widht w, the height h and the point spacing pointSpacing. The direction (point order) can be defined by optional argument dir which can be :acw (default) or :cw. If the point spacing is ommitted only the rectangle corners are returned.
square
Comodo.square — Function
square(w::T; orientation=:up) where T<:RealReturns square face and vertices
Description
This function returns a face f and a vector of corner points for a square. The user can specify the widht w. The direction (point order) can be defined by optional argumentdirwhich can be:acw(default) or:cw`.
squarepoints
Comodo.squarepoints — Function
squarepoints(w::T; dir=:acw) where T<:Real
squarepoints(w::T, pointSpacing::T; dir=:acw) where T<:RealReturns square boundary points
Description
This function returns a vector of points on the boundary of a square. The user can specify the widht w and the point spacing pointSpacing. The direction (point order) can be defined by optional argument dir which can be :acw (default) or :cw. If the point spacing is ommitted only the square corners are returned.
pizza
Comodo.pizza — Function
pizza(r::T, n::TN) where T<:Real where TN<:IntegerReturns cut pizza-like triangle mesh
Description
This function returns the triangular faces F and vertices V for a "cut pizza"-like mesh, i.e. for a circularly arranged set of triangles spanning a circle. The pizza-mesh is created with the input radius r and features n slices (triangles).
barycoord
Comodo.barycoord — Function
barycoord(vf,p,i,a,n)
barycoord(vf,p,i)Computes barycentric coordinate
Description
This function computes the i-th barycentric coordinate for the point p within the triangle defined by the input point vector vf. Optionally one can also provide the triangle face area a and normal direction n, if these have already been computed.
cart2bary
Comodo.cart2bary — Function
cart2bary(f::NgonFace{NF,TF}, V::Vector{Point{ND,TV}}, p::Point{ND,TV}) where NF where TF<:Integer where ND where TV<:RealComputes barycentric coordinates
Description
This function computes the barycentric coordinates for the point p within the triangle defined by the face f and vertices V.
bary2cart
Comodo.bary2cart — Function
bary2cart(f::NgonFace{NF,TF}, V::Vector{Point{ND,TV}}, λ::Point{ND,TV}) where NF where TF<:Integer where ND where TV<:RealComputes Cartesian coordinates from barycentric coordinates
Description
This function computes the Cartesian coordinates for the point p using the triangle defined by the face f, the triangle vertices V and the barycentric coordinates λ.
intriangle
Comodo.intriangle — Function
intriangle(f, V::Vector{Point{ND,TV}}, p::Point{ND,TV}) where ND where TV<:Real
intriangle(f, V::Vector{Point{ND,TV}}, p::Point{ND,TV}, a, n) where ND where TV<:Real
intriangle(f::TriangleFace{TF}, V::Vector{Point{ND,TV}}, P::Vector{Point{ND,TV}}) where ND where TF<:Integer where TV<:Real
intriangle(f::TriangleFace{TF}, V::Vector{Point{ND,TV}}, P::Vector{Point{ND,TV}}, a, n) where ND where TF<:Integer where TV<:RealChecks if point is in triangle
Description
This function computes a boolean which is true if the point p is inside the triangle defined by the face f and the triangle vertices V. Instead of a single face, the input may also feature a vector of triangle faces F. Optionally one can also provide the triangle face area a (or area vector A) and normal direction n (or vector of normal directions), if these have already been computed. In addition one may use a vector of points P.
spacing2numsteps
Comodo.spacing2numsteps — Function
spacing2numsteps(d::T, pointSpacing; close_loop=false) where T<:RealReturns number of steps to achieve spacing
Description
This function takes in the distance (or length) d and the desired point spacing pointSpacing across such a distance and returns the number of points to use across the distance to achieve the points spacing. The optional argument close_loop can be used to set wether the distance is for a closed loop (since the start and end point are the same for these).
hexcylinder
Comodo.hexcylinder — Function
spacing2numsteps(d::T, pointSpacing; close_loop=false) where T<:RealCreates hexahedral mesh of cylinder
Description
This function creates a hexahedral mesh of a cylinder. The input consists of the cylinder radius r and the height h. In addition the parameter n set the number of refinement steps to use for the the quaddisc based creation of the top and bottom surface. The optional argument nh sets the number of steps (in terms of nodes) in the height direction. The default behaviour it to define the cylinder with the 0.0 z level in the centre (direction=:both), however the optional argument direction can also be set to be :positive (up only) or :negative (down only).
equilateraltriangle
Comodo.equilateraltriangle — Function
equilateraltriangle(s=1.0, c=Point{3,Float64}(0.0, 0.0, 0.0))Creates equilateral triangle
Description
This function creates the face f anver vertices V for a single equilateral triangle. The inputs include the edgelength (or width) s (default s=1.0) as well as the centre c (default at origin).
hermiteSegment
Comodo.hermiteSegment — Function
equilateraltriangle(s=1.0, c=Point{3,Float64}(0.0, 0.0, 0.0))Evaluates Hermite spline segment
Description
This function computes n points along a Hermite spline defined by the start point p1 and speed v1, and the end point p2 and speed v2. The implementation uses the nbezier function with the control points: [p1, p1+v1/3.0, p2-v2/3.0, p2] to create the spline.
polycentroid
Comodo.polycentroid — Function
polycentroid(V::Vector{Point{ND,TV}}) where ND where TV<:RealComputes polygon centroid
Description
This function takes in a polygon defined by the point vector V and returns the centroid C.
facecentroid
Comodo.facecentroid — Function
facecentroid(f::NgonFace{N,T}, V::Vector{Point{ND,TV}}) where N where T<:Integer where ND where TV<:Real
facecentroid(F::Union{AbstractVector{NgonFace{M,T}}, AbstractVector{NgonFace{N, T} where N}, AbstractVector{NgonFace}}, V::Vector{Point{ND,TV}}) where {M, ND} where T<:Integer where TV<:RealComputes face centroid
Description
This function takes in a face f for vector of faces F, and the vertices V and returns the face centroid(s).
curve2edges
Comodo.curve2edges — Function
curve2edges(ind::Vector{T}; close_loop=false) where T<:IntegerReturns curve edge vector
Description
This function return and set of edges that span the same nodes as the set of ordered indices ind. The indices in ind should define a curve of consecutive points. If the option close_loop=true (default is false) is used then an edge is added to span from the last to the first point in ind.
subtri_dual
Comodo.subtri_dual — Function
subtri_dual(F::Vector{TriangleFace{TF}}, V::Vector{Point{ND,TV}}, n=1; smooth=true, split_boundary=false, constrain_boundary=false) where TF<:Integer where ND where TV<:RealSubdivides triangles using dual
Description
This function refines triangulated meshes using the face-centered dual. The dual subtriangulation method is sometimes referred to as √3-subdevision (see also [1]). For a closed surface mesh 2k subdivision steps would mean each original triangle now represents 9ᵏ triangles (hence √3 new faces per iteration on average). The implementation here largely follows reference [1] however smoothing can be turned on/off using the smooth option (default is true). In addition, there is the option to contrain the boundary during smoothing by setting constrain_boundary=true (default false). Finally there is the option to split the boundary edges by setting split_boundary=true (default is false).
References
[1] Kobbelt, √3-subdivision, 2000, SIGGRAPH 2000.
rhombicdodecahedron2hex
Comodo.rhombicdodecahedron2hex — Function
rhombicdodecahedron2hex(E::Vector{Rhombicdodeca14{T}},V::Vector{Point{3,TV}}) where T<:Integer where TV<:RealConverts rhombicdodecahedrons to hexahedrons
Description
This function converts the input rhombicdodecahedron elements, defined by the element vector E and the vertex vector V, so a set of hexahedral elements defined by the element vector Eh and the vertex vector Vh. The conversion uses a simple splitting up of the rhombicdodecahedron elements.
hexahedronElement
Comodo.hexahedronElement — Function
hexahedronElement(s::T) where T<:RealCreates single hexahedron element
Description
This function creates a single hexahedral element defined by e, of the type Hex8{Int}, and the vertex vector V. The input s controls the width of the element. The element is centered around the origin.
hex2tet
Comodo.hex2tet — Function
hex2tet(e::Hex8{Int}, meshType = 1)
hex2tet(E::Vector{Hex8{Int}}, meshType = 1)
hex2tet(E::Vector{Hex8{Int}}, meshType::Vector{Int})Converts hexahedra to tetrahedra
Description
This function converts the hexahedral element e or vector of elements E to a vector of tetrahedral elements E_tet. There are many ways to do this conversion. This function implements 14 types of conversion. The conversion type is based on meshType. If meshType is an integer in the range 1-14 then only that type of conversion is used for all hexahedral elements provided. Alternatively the user may let meshType be a vector of integers containing the type definition to use for each corresponding element.
triplyperiodicminimal
Comodo.triplyperiodicminimal — Function
triplyperiodicminimal(v, type=:P)Evaluates triply periodic minimal functions
Description
This function evaluates the triply periodic minimal function of the type type at the coordinate defined by the point v. The point v should be a 3 element abstract vector such as a Point{3,Float}. The following types are supported: type = :P # Schwarz P-surface type = :D # Schwarz D-surface type = :D2 # Schwarz D-surface type = :N # Neovius type = :G # Gyroid type = :IWP # Schoen I-graph-wrapped package type = :FRD # Schoen faces of rhombic-dodecahedron type = :S # Fish-Kocher S-sheet type = :HG # Lidinoid
triplyperiodicminimal_sheet
Comodo.triplyperiodicminimal_sheet — Function
triplyperiodicminimal_sheet(v::T, s=0.25, type=:P) where T <: AbstractVectorEvaluates sheet version of triply periodic minimal functions
Description
This function evaluates the "sheet" version of triply periodic minimal function of the type type at the coordinate defined by the point v. The point v should be a 3 element abstract vector such as a Point{3,Float}. The parameter s sets the sheet centre. If for the regular triplyperiodicminimal we obtain the function value f at the point v, then this function returns max(f-s, s-f).
tpms
Comodo.tpms — Function
tpms(type=:P; x=range(0,2*π,100)::T, y=x::T, z=x::T, level=0.0, cap = true, padValue=1e8, side=:positive) where T <: AbstractVectorComputes triply periodic minimal surfaces
Description
This function evaluates the triply periodic minimal surface of the type type at the coordinates defined the abstract vectors x, y, and z. The See also: triplyperiodicminimal
tpms_sheet
Comodo.tpms_sheet — Function
tpms(type=:P; x=range(0,2*π,100)::T, y=x::T, z=x::T, level=0.0, cap = true, padValue=1e8, side=:positive) where T <: AbstractVectorComputes triply periodic minimal surfaces
Description
This function evaluates the triply periodic minimal sheet surface of the type type at the coordinates defined the abstract vectors x, y, and z. The parameter s controls the sheet centre and the sheet thickness is controlled by level, which is the isosurface level. See also: triplyperiodicminimal_sheet
pointsvd
Comodo.pointsvd — Function
pointsvd(V::Vector{T}) where T <: AbstractVectorPoint vector singular value decomposition
Description
This function computes the singular value decomposition for the points defined by the point vector V.
basisGramSchmidt
Comodo.basisGramSchmidt — Function
basisGramSchmidt(E::Union{Vector{Vec{N,T}},Vector{Point{N,T}}}) where N where T<:RealDerive mutually orthogonal basevectors
This function can be used to obtain a set of mutually orthogonal basis vectors from a set of input vectors. The input is a vector of vectors (e.g. a Vec or Point)
basisGramSchmidt!
Comodo.basisGramSchmidt! — Function
basisGramSchmidt!(E::Union{Vector{Vec{N,T}}, Vector{Point{N,T}}}) where N where T<:RealDerive mutually orthogonal basevectors
See also: basisGramSchmidt
hexvolume
Comodo.hexvolume — Function
hexvolume(e::Hex8{Int}, V::Vector{Point{3,T}}) where T<:Real
hexvolume(E::Vector{Hex8{Int}}, V::Vector{Point{3,T}}) where T<:RealCompute hexahedral element volumes
Description
This function computes hexahedral volumes. The input is either a single hexahedron 'e' or a vector of hexahedra 'E'.
isunique
Comodo.isunique — Function
isunique(X)Checks if all entries are unique
Description
This function checks the entries of X and returns a true if all entries are unique. If a non-unique (repeated) entry is encountered then a false is returned. This function can be useful for instance to check if a face has repeated indices. For instance a TriangleFace{Int}(2,3,3) features the node 3 twice and therefore describes an invalid or collapsed or line-like triangle.
remove_snapped_faces!
Comodo.remove_snapped_faces! — Function
remove_snapped_faces!(F::AbstractVector{NgonFace{N,T}}) where N where T<:IntegerRemoves collapsed edge faces
Description
This function removes faces where the two nodes on an edge have been merged to one. This can occur when mergevertices is used and two edge nodes are very close. In this case the face features a repeated index. For instance in the case of a triangle face where nodes 2 and 3 have been merged it is possible that the face becomes TriangleFace{Int}(1,2,2). This function removes such faces from the input fave vector F. The output indRemove features the indices of the removed faces. This list of indices is useful for instance to remove quantities related to faces, such as a label list C. Using deleteat!(C, indRemove) one would "fix" the label list C to once again correspond to F.
faceedgelattice
Comodo.faceedgelattice — Function
faceedgelattice(F1::Vector{NgonFace{N,TF}}, V1::Vector{Point{ND,TV}}, scaleFactor) where N where TF<:Integer where ND where TV <: RealCreates face edge lattice
Description
This uses the input surface mesh defined by the face vector F and the point vector V, to derive an "edge lattice", i.e. a lattice of faces that span the edges of the input mesh.
subtri_centre
Comodo.subtri_centre — Function
subtri_centre(F::Vector{TriangleFace{TF}}, V::Vector{Point{N,T}}) where N where TF<:Integer where T<:Real
subtri_centre(F::Vector{TriangleFace{TF}}, V::Vector{Point{N,T}}, n::TI) where N where TF<:Integer where T<:Real where TI<:IntegerTriangle splitting using centre
Description
This function takes the input triangles defined by the vector F and the points defined by the vector V and subdevides each triangle by adding a new centre coordinate and forming three new triangles using this centre and the triangle edges. An optional input is n which sets the number of iterations to apply to apply the algorithm for.
removethreeconnected
Comodo.removethreeconnected — Function
removethreeconnected(F::Vector{TriangleFace{TF}}, V::Vector{Point{N,T}}; n=-1) where N where TF<:Integer where T<:RealRemoves 3-connected points
Description
This function takes the input triangles defined by the vector F and the points defined by the vector V and removes points that are connected to only 3 edges. By default the algorithm is applied iterative untill there are no 3-connected sites any more. Usually however only 1 iteration is needed to removed all. The optional keyword argument n can be used to set the maximum number of iterations. The default behaviour is n=-1 resulting in termination once converged.
removethreeconnected!
Comodo.removethreeconnected! — Function
removethreeconnected!(F::Vector{TriangleFace{TF}}, V::Vector{Point{N,T}}; n=-1) where N where TF<:Integer where T<:RealRemoves 3-connected points
Description
This function is the same as removethreeconnected but it overwrites it input.
tri2quad_merge!
Comodo.tri2quad_merge! — Function
tri2quad_merge!(F::Vector{TriangleFace{TF}}, V::Vector{Point{N,T}}; numSmoothSteps=0) where N where TF<:Integer where T<:RealAdjacent triangles to quads
Description
This function aims to conver the triangles in the vector F to quadrilateral elements in the output vector Fq. The method does this by merging triangles that share an edge and which produce a high enough quality quadrilateral. First a candidate quadrilateral is created for each edge in the input triangulation. Next a quadrilateral quality metric is computed, namely the maximum angle deviation from orthogonal, for each quad corner. If the maximum angle deviation is lower than the angleThreshold (default is 45.0) then the quad may be kept. The algoritm starts with the best quad and procedes by continuously selecting the next best quad. At some point no new quads can be formed and the algorithm terminates. Unconverted, left over, triangles are next returned in the vector Ft. Finally, the mesh is smoothed using numSmoothSteps smoothing iterations (default is 25).
tri2quad_merge_split!
Comodo.tri2quad_merge_split! — Function
tri2quad_merge_split!(F::Vector{TriangleFace{TF}}, V::Vector{Point{N,T}}; angleThreshold=45.0, numSmoothSteps=25) where N where TF<:Integer where T<:RealTriangulation to quadrangulation through merging and splitting
Description
This function converts the input triangulation defined by the face vector F and the points V to a quadrangulation defined by Fq and Vq. The function first uses tri2quad_merge! with the aim of creating a quad dominated mesh. Next the remaining triangles are split into 3 quads each and the quads are split into 4 quads each. The result is a quadrangulation that is 1 step refined with respect to the input mesh. The third output indInitial provides the indices of the input points. Optional keyword arguments include the angleThreshold (default is 45.0) and numSmoothSteps smoothing iterations (default is 25), see also see tri2quad_merge!.
tri2def
Comodo.tri2def — Function
tri2def(P1::Vector{Point{N,T}}, P2::Vector{Point{N,T}}) where N where T<:Real
tri2def(f::TriangleFace{Tf}, P1::Vector{Point{N,T}}, P2::Vector{Point{N,T}}) where Tf<:Integer where N where T<:Real
tri2def(F::Vector{TriangleFace{Tf}}, P1::Vector{Point{N,T}}, P2::Vector{Point{N,T}}) where Tf<:Integer where N where T<:RealComputes triagle deformation gradient tensor
Description
This function computes triangle deformation gradient tensors. The input consits of the initial and final point vectors P1 and P2 respectively. If no face(s) are provided then these points should define triplets such that a triangle is formed by the three points in the point sets. If a single face f is provided then the indices in f are used to define the triangle. If a single triangle is defined the output is a single 3x3 Matrix{Float} defining the triangles deformation gradient tensor. If instead a vector of triangles F is provided, then the output consists of a vector of such matrices.
polarDecomposition
Comodo.polarDecomposition — Function
polarDecomposition(F)Computes polar decomposition of deformation gradient tensor
Description
This function computes the polar decomposition of the input deformation gradient tensor F, which should be a 3x3 Matrix{Float} or equivalent. The output consits of: U the right stretch tensor V the left stretch tensor Q the rotation tensor part of F W in the SVD W, Σ, R = svd(F) Σ a vector containing the principal Stretches R in the SVD W, Σ, R = svd(F)