Skip to content

example from README.md broken #36

@gwater

Description

@gwater

The example given in README

using Meshing
using GeometryTypes
using LinearAlgebra: dot, norm
using FileIO

# Mesh an equation of sphere in the Axis-Aligned Bounding box starting
# at -1,-1,-1 and widths of 2,2,2
m = GLNormalMesh(HyperRectangle(Vec(-1,-1,-1.), Vec(2,2,2.)), MarchingCubes()) do v
    sqrt(sum(dot(v,v))) - 1
end

# save the Sphere as a PLY file
save("sphere.ply",m)

causes the following error

MethodError: no method matching GLNormalMesh(::getfield(Main, Symbol("##3#4")), ::HyperRectangle{3,Float64}, ::MarchingCubes{Float64})
Closest candidates are:
  GLNormalMesh(::Any, ::Any, ::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any) where {VertT, FaceT, NormalT, TexCoordT, ColorT, AttribT, AttribIDT} at /home/jgraw/.julia/packages/GeometryTypes/ETYtg/src/types.jl:167
  GLNormalMesh(!Matched::GeometryPrimitive, ::Any...) where T<:AbstractMesh at /home/jgraw/.julia/packages/GeometryTypes/ETYtg/src/primitives.jl:14
  GLNormalMesh(!Matched::AbstractMesh, ::ConstAttrib) where {HM<:HomogenousMesh, ConstAttrib} at /home/jgraw/.julia/packages/GeometryTypes/ETYtg/src/meshes.jl:132
  ...

Apparently, GLNormalMesh does not provide the convenience of constructing a SignedDistanceField automatically. Constructing the SDF manually works:

using Meshing
using GeometryTypes
using LinearAlgebra
using FileIO

# Mesh an equation of sphere in the Axis-Aligned Bounding box starting
# at -1,-1,-1 and widths of 2,2,2
sdf = SignedDistanceField(HyperRectangle(Vec3f0(-1), Vec3f0(2))) do v
    return v ⋅ v - 1
end
m = GLNormalMesh(sdf, MarchingTetrahedra())

# save the Sphere as a PLY file
save("sphere.ply", m)

In addition the example requires MeshIO.jl which should be noted as a prerequisite for the example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions