Functions
comododir
Comodo.comododir
— Functioncomododir()
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
— Functionslidercontrol(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
— Functionslider2anim(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
— Functionelements2indices(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
— Functiongridpoints(x::Vector{T}, y=x, z=x) where T<:Real
Returns 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
— Functiongridpoints_equilateral(xSpan,ySpan,pointSpacing::T; return_faces = false, rectangular=false) where T <: Real
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
— Functioninterp_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<:Real
Interpolates 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. consequtive 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
interp_biharmonic
Comodo.interp_biharmonic
— Functioninterp_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
— Functionnbezier(P,n)
Returns a Bezier spline for the control points P whose order matches the numbe 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
— Functionlerp(x::Union{T,Vector{T}, AbstractRange{T}},y,xi::Union{T,Vector{T}, AbstractRange{T}}) where T <: Real
Linear interpolation
Description
This linearly interpolates (lerps) the input data specified by the sites x
and data y
at the specified sites xi
.
dist
Comodo.dist
— Functiondist(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
— Functionmindist(V1,V2; getIndex=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.
unique_dict_index
Comodo.unique_dict_index
— Functionunique_dict_index(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values and indices
Description
Returns the unique entries in X
as well as the indices for them. 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_dict_index_inverse
Comodo.unique_dict_index_inverse
— Functionunique_dict_index_inverse(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values, indices, and inverse indices
Description
Returns the unique entries in X
as well as the indices for them and the reverse indices to retrieve the original from the unique entries. 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_dict_index_count
Comodo.unique_dict_index_count
— Functionunique_dict_index_count(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values, indices, and counts
Description
Returns the unique entries in X
as well as the indices for them and the counts in terms of how often they occured. 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_dict_index_inverse_count
Comodo.unique_dict_index_inverse_count
— Functionunique_dict_index_inverse_count(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values, indices, inverse indices, and counts
Description
Returns the unique entries in X
as well as the indices for them and the reverse indices to retrieve the original from the unique entries, and also the counts in terms of how often they occured. 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_dict_count
Comodo.unique_dict_count
— Functionunique_dict_count(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values and counts
Description
Returns the unique entries in X
as well as the counts in terms of how often they occured. 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_dict_inverse
Comodo.unique_dict_inverse
— Functionunique_dict_inverse(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values and inverse indices
Description
Returns the unique entries in X
as well as the reverse indices to retrieve the original from the unique entries. 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_dict
Comodo.unique_dict
— Functionunique_dict(X::AbstractVector{T}) where T <: Real
Returns unique values, indices, and inverse indices. Uses an OrderedDict.
Description
Returns the unique entries in X
as well as the indices for them and the reverse indices to retrieve the original from the unique entries.
gunique
Comodo.gunique
— Functiongunique(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
— Functionunique_simplices(F,V=nothing)
Returns unique simplices (such as faces), independant 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
— Functionind2sub(siz,ind)
Converts linear indices to subscript indices.
Description
Converts the linear indices in ind
, for a matrix/array with size siz
, to the equivalent subscript indices.
sub2ind
Comodo.sub2ind
— Functionsub2ind(siz,A)
Converts subscript indices to linear indices.
Description
Converts the subscript indices in A
, for a matrix/array with size siz
, to the equivalent linear indices.
meshedges
Comodo.meshedges
— Functionmeshedges(F::Array{NgonFace{N,T},1}; unique_only=false) where N where T<:Integer
Returns 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
— Functionicosahedron(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
— Functionoctahedron(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
— Functiondodecahedron(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
— Functioncube(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
— Functiontetrahedron(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
— Functionplatonicsolid(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
— Functiontofaces(FM::Vector{Vector{TF}}) where TF<:Integer
+Functions · A Julia package for computational (bio)mechanics and computational design Functions
comododir
Comodo.comododir
— Functioncomododir()
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.
sourceslidercontrol
Comodo.slidercontrol
— Functionslidercontrol(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.
sourceslider2anim
Comodo.slider2anim
— Functionslider2anim(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
sourceelements2indices
Comodo.elements2indices
— Functionelements2indices(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.
sourcegridpoints
Comodo.gridpoints
— Functiongridpoints(x::Vector{T}, y=x, z=x) where T<:Real
Returns 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
.
sourcegridpoints_equilateral
Comodo.gridpoints_equilateral
— Functiongridpoints_equilateral(xSpan,ySpan,pointSpacing::T; return_faces = false, rectangular=false) where T <: Real
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.
sourceinterp_biharmonic_spline
Comodo.interp_biharmonic_spline
— Functioninterp_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<:Real
Interpolates 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. consequtive 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
sourceinterp_biharmonic
Comodo.interp_biharmonic
— Functioninterp_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
sourcenbezier
Comodo.nbezier
— Functionnbezier(P,n)
Returns a Bezier spline for the control points P whose order matches the numbe 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}
.
sourcelerp
Comodo.lerp
— Functionlerp(x::Union{T,Vector{T}, AbstractRange{T}},y,xi::Union{T,Vector{T}, AbstractRange{T}}) where T <: Real
Linear interpolation
Description
This linearly interpolates (lerps) the input data specified by the sites x
and data y
at the specified sites xi
.
sourcedist
Comodo.dist
— Functiondist(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
sourcemindist
Comodo.mindist
— Functionmindist(V1,V2; getIndex=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.
sourceunique_dict_index
Comodo.unique_dict_index
— Functionunique_dict_index(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values and indices
Description
Returns the unique entries in X
as well as the indices for them. 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.
sourceunique_dict_index_inverse
Comodo.unique_dict_index_inverse
— Functionunique_dict_index_inverse(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values, indices, and inverse indices
Description
Returns the unique entries in X
as well as the indices for them and the reverse indices to retrieve the original from the unique entries. 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.
sourceunique_dict_index_count
Comodo.unique_dict_index_count
— Functionunique_dict_index_count(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values, indices, and counts
Description
Returns the unique entries in X
as well as the indices for them and the counts in terms of how often they occured. 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.
sourceunique_dict_index_inverse_count
Comodo.unique_dict_index_inverse_count
— Functionunique_dict_index_inverse_count(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values, indices, inverse indices, and counts
Description
Returns the unique entries in X
as well as the indices for them and the reverse indices to retrieve the original from the unique entries, and also the counts in terms of how often they occured. 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.
sourceunique_dict_count
Comodo.unique_dict_count
— Functionunique_dict_count(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values and counts
Description
Returns the unique entries in X
as well as the counts in terms of how often they occured. 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.
sourceunique_dict_inverse
Comodo.unique_dict_inverse
— Functionunique_dict_inverse(X::Union{Array{T},Tuple{T}}; sort_entries=false) where T <: Any
Returns unique values and inverse indices
Description
Returns the unique entries in X
as well as the reverse indices to retrieve the original from the unique entries. 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.
sourceunique_dict
Comodo.unique_dict
— Functionunique_dict(X::AbstractVector{T}) where T <: Real
Returns unique values, indices, and inverse indices. Uses an OrderedDict.
Description
Returns the unique entries in X
as well as the indices for them and the reverse indices to retrieve the original from the unique entries.
sourcegunique
Comodo.gunique
— Functiongunique(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.
sourceunique_simplices
Comodo.unique_simplices
— Functionunique_simplices(F,V=nothing)
Returns unique simplices (such as faces), independant 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.
sourceind2sub
Comodo.ind2sub
— Functionind2sub(siz,ind)
Converts linear indices to subscript indices.
Description
Converts the linear indices in ind
, for a matrix/array with size siz
, to the equivalent subscript indices.
sourcesub2ind
Comodo.sub2ind
— Functionsub2ind(siz,A)
Converts subscript indices to linear indices.
Description
Converts the subscript indices in A
, for a matrix/array with size siz
, to the equivalent linear indices.
sourcemeshedges
Comodo.meshedges
— Functionmeshedges(F::Array{NgonFace{N,T},1}; unique_only=false) where N where T<:Integer
Returns 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.
sourceicosahedron
Comodo.icosahedron
— Functionicosahedron(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
.
sourceoctahedron
Comodo.octahedron
— Functionoctahedron(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
.
sourcedodecahedron
Comodo.dodecahedron
— Functiondodecahedron(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
.
sourcecube
Comodo.cube
— Functioncube(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
.
sourcetetrahedron
Comodo.tetrahedron
— Functiontetrahedron(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
.
sourceplatonicsolid
Comodo.platonicsolid
— Functionplatonicsolid(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
sourcetofaces
Comodo.tofaces
— Functiontofaces(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 <: Integer
Converts 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 intput is already of the right type this function leaves the input unchanged.
sourcetopoints
Comodo.topoints
— Functiontopoints(VM::Matrix{T}) where T<: Real
+tofaces(FM::Vector{NgonFace{m, TF}} ) where m where TF <: Integer
Converts 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 intput is already of the right type this function leaves the input unchanged.
sourcetopoints
Comodo.topoints
— Functiontopoints(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 <: Real
Converts 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.
sourcetogeometrybasics_mesh
Comodo.togeometrybasics_mesh
— Functiontogeometrybasics_mesh
Converts 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.
sourceedgecrossproduct
Comodo.edgecrossproduct
— Functionedgecrossproduct(F,V::Vector{Point{ND,T}}) where ND where T<:Real
-edgecrossproduct(M::GeometryBasics.Mesh)
Returns the edge cross product, useful for nomal direction and area computations.
# Description
This function computes the so-called edge-cross-product for a input mesh that is either defined by the faces F
and vertices V
or the mesh M
.
sourcefacenormal
Comodo.facenormal
— Functionfacenormal(F,V; weighting=:area)
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
.
sourcefacearea
Comodo.facearea
— Functionfacearea(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
.
sourcevertexnormal
Comodo.vertexnormal
— Functionvertexnormal(F,V; weighting=:area)
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=:area
(default), then the average is weighted based on the face areas.
sourceedgelengths
Comodo.edgelengths
— Functionedgelengths(E::LineFace,V)
+topoints(VM::Vector{Point{ND,TV}}) where ND where TV <: Real
Converts 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.
sourcetogeometrybasics_mesh
Comodo.togeometrybasics_mesh
— Functiontogeometrybasics_mesh
Converts 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.
sourceedgecrossproduct
Comodo.edgecrossproduct
— Functionedgecrossproduct(F,V::Vector{Point{ND,T}}) where ND where T<:Real
+edgecrossproduct(M::GeometryBasics.Mesh)
Returns the edge cross product, useful for nomal direction and area computations.
# Description
This function computes the so-called edge-cross-product for a input mesh that is either defined by the faces F
and vertices V
or the mesh M
.
sourcefacenormal
Comodo.facenormal
— Functionfacenormal(F,V; weighting=:area)
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
.
sourcefacearea
Comodo.facearea
— Functionfacearea(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
.
sourcevertexnormal
Comodo.vertexnormal
— Functionvertexnormal(F,V; weighting=:area)
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=:area
(default), then the average is weighted based on the face areas.
sourceedgelengths
Comodo.edgelengths
— Functionedgelengths(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
.
sourcesubtri
Comodo.subtri
— Functionsubtri(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
sourcesubquad
Comodo.subquad
— Functionsubquad(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 <: Real
Refines 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
sourcegeosphere
Comodo.geosphere
— Functiongeosphere(n::Int,r::T) where T <: Real
Returns 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 lenghts. The algorithm starts with a regular icosahedron. Next this icosahedron is refined n
times, while nodes are pushed to a sphere surface with radius r
at each iteration.
sourcehexbox
Comodo.hexbox
— Functionhexbox(boxDim,boxEl)
Returns a hexahedral mesh of a box
Description
This function returns a hexahedral mesh for a 3D rectangular box domain.
sourcecon_face_edge
Comodo.con_face_edge
— Functioncon_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.
sourcecon_edge_face
Comodo.con_edge_face
— Functionconedgeface(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.
sourcecon_face_face
Comodo.con_face_face
— Functioncon_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 save time.
sourcecon_face_face_v
Comodo.con_face_face_v
— Functioncon_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 neede, 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.
sourcecon_vertex_simplex
Comodo.con_vertex_simplex
— Functioncon_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
.
sourcecon_vertex_face
Comodo.con_vertex_face
— Functioncon_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
.
sourcecon_vertex_edge
Comodo.con_vertex_edge
— Functioncon_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
.
sourcecon_edge_edge
Comodo.con_edge_edge
— Functioncon_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.
sourcecon_vertex_vertex_f
Comodo.con_vertex_vertex_f
— Functioncon_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.
sourcecon_vertex_vertex
Comodo.con_vertex_vertex
— Functioncon_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.
sourcemeshconnectivity
Comodo.meshconnectivity
— Functionmeshconnectivity(F::Vector{NgonFace{N,TF}},V::Vector{Point{ND,TV}}) where N where TF<:Integer where ND where TV<:Real
Returns 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)
sourcemergevertices
Comodo.mergevertices
— Functionmergevertices(F::Vector{NgonFace{N,TF}},V::Vector{Point{ND,TV}}; roundVertices = true, numDigitsMerge=nothing) where N where TF<:Integer where ND where TV<:Real
Merges 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.
sourcesmoothmesh_laplacian
Comodo.smoothmesh_laplacian
— Functionsmoothmesh_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.
sourcesmoothmesh_hc
Comodo.smoothmesh_hc
— Functionsmoothmesh_hc(F,V, con_V2V=nothing; n=1, α=0.1, β=0.5, tolDist=nothing)
Description
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.
Reference
sourcequadplate
Comodo.quadplate
— Functionquadplate(plateDim,plateElem)
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
.
sourcequadsphere
Comodo.quadsphere
— Functionquadsphere(n::Int,r::T) where T <: Real
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 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.
sourceloflinear
Comodo.loftlinear
— Functionloftlinear(V1,V2;num_steps=2,close_loop=true,face_type=:tri)
Loft a surface mesh between two input 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-vector V2::Vector
: n-vector
sourcepointspacingmean
Comodo.pointspacingmean
— Functionpointspacingmean(V::Vector{Point3{Float64}})
-pointspacingmean(F::Array{NgonFace{N, Int}, 1},V::Vector{Point3{Float64}}) where N
The pointspacingmean
function computes the mean spacing between points. The input can be just the coordinate set V
, a vector of Point3 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 faces
F` is provided then edges are first computed after which the mean edge spacing is return.
sourceray_triangle_intersect
Comodo.ray_triangle_intersect
— Functionray_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 wether the vector is treated as a ray (extends indefinately) 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 allong face normal) When triSide=0
both inward and outward intersections are considered. tolEps = eps(Float64)
(default)
References
sourcemesh_curvature_polynomial
Comodo.mesh_curvature_polynomial
— Functionmesh_curvature_polynomial(F::Vector{TriangleFace{Int}},V::Vector{Point3{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
sourceseparate_vertices
Comodo.separate_vertices
— Functionseparate_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)
.
sourceevenly_sample
Comodo.evenly_sample
— Functionevenly_sample(V::Vector{Point{ND,TV}}, n::Int; rtol = 1e-8, niter = 1) where ND where TV<:Real
Evenly 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 allong B-spline distance being uniform).
sourceinvert_faces
Comodo.invert_faces
— Functioninvert_faces(F::Vector{NgonFace{N, TF}, 1}) where N where TF<:Integer
Flips 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.
sourcekabsch_rot
Comodo.kabsch_rot
— FunctionR = kabsch_rot(V1::Array{Point{N, T}, 1},V2::Array{Point{N, TT}, 1}) where N where T<:Real where TT<:Real
Description
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
sourcesweeploft
Comodo.sweeploft
— FunctionF,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 allong 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.
sourcerevolvecurve
Comodo.revolvecurve
— Functionrevolvecurve(Vc::Vector{Point{ND,TV}}; extent = 2.0*pi, 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<:Real
Revolves 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
.
sourcebatman
Comodo.batman
— Functionbatman(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 forces exactly n
points which may result in an assymetric curve. To instead force symmetry the user can set the optional parameter symmetric=true
. In this case the output will be symmetric allong the y-axis, however the number of points on the curve may have increased (if the input n
is not even). The second optional input is the direction of the curve, i.e. if it is clockwise, dir=:cw
or anti-clockwise dir=:acw
. The implementation is based on a "parameterised Batman equation" 1. The following modifications where made, the curve is here centered around [0,0,0], scaled to be 2 in width, resampled evenly, and the default curve direction is anti-clockwise.
References
- https://www.desmos.com/calculator/ajnzwedvql
sourcetridisc
Comodo.tridisc
— Functiontridisc(r=1.0,n=0)
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 circular coordinate correction to obtain the final mesh.
sourceregiontrimesh
Comodo.regiontrimesh
— Functionregiontrimesh(VT,R,P)
Description
Generates a multi-region triangle mesh for the input regions. The boundary curves for all regions are containedin the tuple VT
. Each region to be meshed is next defined using a tuple R
containing indices into the curve typle 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.
sourcescalesimplex
Comodo.scalesimplex
— Functionscalesimplex(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.
sourcesubcurve
Comodo.subcurve
— Functionsubcurve(V,n)
Adds n
points between each curve point.
Description
This function adds n
points between each current point on the curve V
.
sourceSettings
This document was generated with Documenter.jl version 1.5.0 on Tuesday 9 July 2024. Using Julia version 1.10.4.
+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
— Functionsubtri(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
— Functionsubquad(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 <: Real
Refines 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
geosphere
Comodo.geosphere
— Functiongeosphere(n::Int,r::T) where T <: Real
Returns 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 lenghts. The algorithm starts with a regular icosahedron. Next this icosahedron is refined n
times, while nodes are pushed to a sphere surface with radius r
at each iteration.
hexbox
Comodo.hexbox
— Functionhexbox(boxDim,boxEl)
Returns a hexahedral mesh of a box
Description
This function returns a hexahedral mesh for a 3D rectangular box domain.
con_face_edge
Comodo.con_face_edge
— Functioncon_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
— Functionconedgeface(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
— Functioncon_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 save time.
con_face_face_v
Comodo.con_face_face_v
— Functioncon_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 neede, 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
— Functioncon_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
— Functioncon_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
— Functioncon_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
— Functioncon_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
— Functioncon_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
— Functioncon_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
— Functionmeshconnectivity(F::Vector{NgonFace{N,TF}},V::Vector{Point{ND,TV}}) where N where TF<:Integer where ND where TV<:Real
Returns 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
— Functionmergevertices(F::Vector{NgonFace{N,TF}},V::Vector{Point{ND,TV}}; roundVertices = true, numDigitsMerge=nothing) where N where TF<:Integer where ND where TV<:Real
Merges 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
— Functionsmoothmesh_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
— Functionsmoothmesh_hc(F,V, con_V2V=nothing; n=1, α=0.1, β=0.5, tolDist=nothing)
Description
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.
Reference
quadplate
Comodo.quadplate
— Functionquadplate(plateDim,plateElem)
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
— Functionquadsphere(n::Int,r::T) where T <: Real
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 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.
loflinear
Comodo.loftlinear
— Functionloftlinear(V1,V2;num_steps=2,close_loop=true,face_type=:tri)
Loft a surface mesh between two input 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
pointspacingmean
Comodo.pointspacingmean
— Functionpointspacingmean(V::Vector{Point3{Float64}})
+pointspacingmean(F::Array{NgonFace{N, Int}, 1},V::Vector{Point3{Float64}}) where N
The pointspacingmean
function computes the mean spacing between points. The input can be just the coordinate set V
, a vector of Point3 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 faces
F` is provided then edges are first computed after which the mean edge spacing is return.
ray_triangle_intersect
Comodo.ray_triangle_intersect
— Functionray_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 wether the vector is treated as a ray (extends indefinately) 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 allong face normal) When triSide=0
both inward and outward intersections are considered. tolEps = eps(Float64)
(default)
References
mesh_curvature_polynomial
Comodo.mesh_curvature_polynomial
— Functionmesh_curvature_polynomial(F::Vector{TriangleFace{Int}},V::Vector{Point3{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
— Functionseparate_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
— Functionevenly_sample(V::Vector{Point{ND,TV}}, n::Int; rtol = 1e-8, niter = 1) where ND where TV<:Real
Evenly 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 allong B-spline distance being uniform).
invert_faces
Comodo.invert_faces
— Functioninvert_faces(F::Vector{NgonFace{N, TF}, 1}) where N where TF<:Integer
Flips 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
— FunctionR = kabsch_rot(V1::Array{Point{N, T}, 1},V2::Array{Point{N, TT}, 1}) where N where T<:Real where TT<:Real
Description
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
— FunctionF,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 allong 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
— Functionrevolvecurve(Vc::Vector{Point{ND,TV}}; extent = 2.0*pi, 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<:Real
Revolves 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
— Functionbatman(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 forces exactly n
points which may result in an assymetric curve. To instead force symmetry the user can set the optional parameter symmetric=true
. In this case the output will be symmetric allong the y-axis, however the number of points on the curve may have increased (if the input n
is not even). The second optional input is the direction of the curve, i.e. if it is clockwise, dir=:cw
or anti-clockwise dir=:acw
. The implementation is based on a "parameterised Batman equation" 1. The following modifications where made, the curve is here centered around [0,0,0], scaled to be 2 in width, resampled evenly, and the default curve direction is anti-clockwise.
References
- https://www.desmos.com/calculator/ajnzwedvql
tridisc
Comodo.tridisc
— Functiontridisc(r=1.0,n=0)
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 circular coordinate correction to obtain the final mesh.
regiontrimesh
Comodo.regiontrimesh
— Functionregiontrimesh(VT,R,P)
Description
Generates a multi-region triangle mesh for the input regions. The boundary curves for all regions are containedin the tuple VT
. Each region to be meshed is next defined using a tuple R
containing indices into the curve typle 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
— Functionscalesimplex(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
— Functionsubcurve(V,n)
Adds n
points between each curve point.
Description
This function adds n
points between each current point on the curve V
.