Line data Source code
1 : include("off/readoff.jl")
2 : include("off/writeoff.jl")
3 :
4 : """
5 : Delegate to [`readoffmesh`](@ref)
6 : """
7 2 : function readmesh(io::IO, ::OFF, template::Mesh;
8 : position=Val(:x),
9 : normal=nothing,
10 : texcoord=Val(:u),
11 : color=Val(:c),
12 : real_type=Float64, index_type=Int32, color_type=RGBA,
13 : kargs...)
14 1 : readoffmesh(io, template;
15 : position, normal, texcoord, color,
16 : real_type, index_type, color_type,
17 : kargs...)
18 : end
19 :
20 : """
21 : Delegate to [`writeoffmesh`](@ref)
22 : """
23 2 : function writemesh(io::IO, ::OFF, mesh::Mesh;
24 : position=Val(:x),
25 : normal=nothing,
26 : texcoord=Val(:u),
27 : color=Val(:c),
28 : format::String="%g",
29 : kargs...)
30 1 : writeoffmesh(io, mesh;
31 : position, normal, texcoord, color, format, kargs...)
32 : end
33 :
34 : """
35 : mesh = createmesh(::OFF[; real_type=Float64, dimx=Val(3), dimu=Val(2)])
36 :
37 : Create an empty mesh with all attributes that may be read from an
38 : OFF file: position, normal, and texture coordinates:
39 :
40 : - vertex attributes `:x`, `:n`, `:u`, `:c`
41 : - face attributes: `:n`
42 :
43 : The latter stores texture coordinates and normals that are defined for
44 : each vertex of a face.
45 :
46 : !!! note
47 : This method uses default attribute names `:x`, `:n`, `:u`, `:c`!
48 : """
49 0 : function PMesh.createmesh(::OFF; real_type::Type{T}=Float64,
50 : dimx::Val{Nx}=Val(3),
51 : dimu::Val{Nu}=Val(2)) where {T<:Real, Nx, Nu}
52 0 : _createoffmesh(real_type, dimx, dimu)
53 : end
54 :
55 :
56 0 : function _createoffmesh(real_type::Type{T}, ::Val{Nx}, ::Val{Nu}) where {T, Nx, Nu}
57 0 : PMesh.createmesh((:x => SVector{Nx, real_type},
58 : :u => SVector{Nu, real_type},
59 : :n => SVector{3, real_type},
60 : :c => RGBA),
61 : (:n => SVector{3, real_type}),
62 : (),
63 : ())
64 : end
65 :
66 0 : function _createoffmesh(real_type::Type{T}, ::Val{Nx}, ::Val{1}) where {T, Nx}
67 0 : PMesh.createmesh((:x => SVector{Nx, real_type},
68 : :u => real_type,
69 : :n => SVector{3, real_type},
70 : :c => RGBA),
71 : (:n => SVector{3, real_type}),
72 : (),
73 : ())
74 : end
|