JuliaGeometry / GeometryBasics.jl

Basic Geometry Types
MIT License
165 stars 54 forks source link

FaceView Documentation, MethodError: no method matching FaceView(::Vector{Point{3, Float32}}, ::Vector{TriangleFace}) #202

Open mkitti opened 12 months ago

mkitti commented 12 months ago

The following example is included in the documentation for FaceView, but no longer functions.

x = FaceView(rand(Point3f, 10), TriangleFace[(1, 2, 3), (2, 4, 5), ...])
x[1] isa Triangle == true
x isa AbstractVector{<: Triangle} == true
# This means we can use it as a mesh:
Mesh(x) # should just work!
# Can also be used for Points:

linestring = FaceView(points, LineFace[...])
Polygon(linestring)

https://github.com/JuliaGeometry/GeometryBasics.jl/blob/89b857e33e8c33d1304d1630836b4d0b466869ef/src/viewtypes.jl#L105-L122

julia> using GeometryBasics

julia> x = FaceView(rand(Point3f, 10), TriangleFace[(1, 2, 3), (2, 4, 5)])
ERROR: MethodError: no method matching FaceView(::Vector{Point{3, Float32}}, ::Vector{TriangleFace})
mkitti commented 12 months ago

Perhaps the closest function code is

julia> using GeometryBasics

julia> x = Mesh(rand(Point3f, 10), TriangleFace{Int}[(1, 2, 3), (2, 4, 5)])
Mesh{3, Float32, Triangle}:
 Triangle(Float32[0.01959169, 0.27225375, 0.013921678], Float32[0.6437949, 0.9430128, 0.59738755], Float32[0.49121314, 0.80466264, 0.8372437])
 Triangle(Float32[0.6437949, 0.9430128, 0.59738755], Float32[0.81211555, 0.6806344, 0.15718842], Float32[0.7763256, 0.033540606, 0.6247859])

julia> x[1] isa Triangle
true

julia> x isa AbstractVector{<: Triangle}
true

julia> Mesh(x)
Mesh{3, Float32, Triangle}:
 Triangle(Float32[0.01959169, 0.27225375, 0.013921678], Float32[0.6437949, 0.9430128, 0.59738755], Float32[0.49121314, 0.80466264, 0.8372437])
 Triangle(Float32[0.6437949, 0.9430128, 0.59738755], Float32[0.81211555, 0.6806344, 0.15718842], Float32[0.7763256, 0.033540606, 0.6247859])

Is FaceView still needed?