Using the API to extend the geometry types
The solver handles hole and face (plane) features that are either IsPrimitive
or IsFreeForm
. A few basic types are defined like SimpleHole
and MeshHole
, but new ones can be also defined. For example for point clouds, that don't have faces, like a mesh, only points.
This capability is properly documented, as a major API rewrite is going on in #3.
Defining a new geometry
Defining a new geometry is pretty easy:
- It has to be the subtype of either
AbstractHoleGeometry
orAbstractPlaneGeometry
. - The
GeometryStyle
trait is need to be defined: it is either aIsPrimitive
orIsFreeForm
geometry. IsFreeForm
geometries need to define thesurfacepoints
andfilteredsurfacepoints
functions.IsPrimitive
geometries need to define thefeaturepoint
functions- Those
IsPrimitive
geometries that are subtype ofAbstractHoleGeometry
also need to define thefeatureradius
function - Finally, for visualization purposes the
visualizationgeometry
function should be defined, that returns an object, that can be used with theMeshviz.viz()
function.
An example
Let's assume that we want to define a new holelike type: MyDisk
, which has a featurepoint, a normal, and a radius.
using BlankLocalizationCore
struct MyDisk <: AbstractHoleGeometry
point::Vector{Float64}
normal::Vector{Float64}
diameter::Float64
end
GeometryStyle(::Type{MyDisk}) = IsPrimitive()
It is an IsPrimitive
and holelike feature, therefore we need to define the:
featurepoint
featureradius
visualizationgeometry
functions. These look like as follows:
featurepoint(::IsPrimitive, x::MyDisk) = x.point
featureradius(::IsPrimitive, x::MyDisk) = x.diameter/2
using Meshes
function visualizationgeometry(geom::MyDisk)
plane = Plane(Point3(geom.point), Vec3(geom.normal))
return Disk(plane, geom.diameter/2)
end