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
AbstractHoleGeometryorAbstractPlaneGeometry. - The
GeometryStyletrait is need to be defined: it is either aIsPrimitiveorIsFreeFormgeometry. IsFreeFormgeometries need to define thesurfacepointsandfilteredsurfacepointsfunctions.IsPrimitivegeometries need to define thefeaturepointfunctions- Those
IsPrimitivegeometries that are subtype ofAbstractHoleGeometryalso need to define thefeatureradiusfunction - Finally, for visualization purposes the
visualizationgeometryfunction 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:
featurepointfeatureradiusvisualizationgeometry
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