|
1 | 1 | using WriteVTK |
2 | | - |
| 2 | +using ExtensionErrors |
3 | 3 | # conversion from AbstractElementGeometry to WriteVTK.VTKCellTypes |
4 | 4 | WriteVTK.VTKCellType(::Type{<:AbstractElementGeometry1D}) = VTKCellTypes.VTK_LINE |
5 | 5 | WriteVTK.VTKCellType(::Type{<:Triangle2D}) = VTKCellTypes.VTK_TRIANGLE |
6 | 6 | WriteVTK.VTKCellType(::Type{<:Quadrilateral2D}) = VTKCellTypes.VTK_QUAD |
7 | 7 | WriteVTK.VTKCellType(::Type{<:Tetrahedron3D}) = VTKCellTypes.VTK_TETRA |
8 | 8 | WriteVTK.VTKCellType(::Type{<:Hexahedron3D}) = VTKCellTypes.VTK_HEXAHEDRON |
9 | 9 |
|
10 | | -struct ExtensionLoadError <: Exception |
11 | | - fname::Symbol |
12 | | - weakdeps::Vector{Symbol} |
13 | | -end |
14 | | - |
15 | | -Base.showerror(io::IO, e::ExtensionLoadError) = |
16 | | - print( |
17 | | - io, |
18 | | - "ExtensionLoadError: " |
19 | | - * "The function " * String(e.fname) * " is part of an extension.\n" |
20 | | - * "Suggestion: Install and load the following modules:" |
21 | | - * mapreduce(x -> "\n" * x, *, String.(e.weakdeps)) |
22 | | -) |
23 | | - |
24 | | -struct ExtensionMethodError <: Exception |
25 | | - fn::Function |
26 | | - args::Tuple |
27 | | -end |
28 | | - |
29 | | - |
30 | | -function Base.showerror(io::IO, e::ExtensionMethodError) |
31 | | - fname = String(nameof(e.fn)) |
32 | | - argtypes = typeof.(e.args) |
33 | | - println(io, |
34 | | - "ExtensionMethodError: no method matching " * fname |
35 | | - * "(" * join(map(x-> "::"*String(nameof(x)),argtypes),',') |
36 | | - * ")") |
37 | | - println(io,"The function " * fname * " exists in a loaded extension," |
38 | | - *" but no method is defined for this combination of argument types.\n" |
39 | | - * "\nCandidates are:\n" |
40 | | - ) |
41 | | - println.(io, filter(x -> x != which(e.fn, (argtypes...,)), methods(e.fn))) |
42 | | - return nothing |
43 | | -end |
44 | | - |
45 | | -function prepare_extension_function(fname::Symbol, weakdeps::Vector{Symbol}, args::Vector{Symbol}) |
46 | | - expr = quote |
47 | | - function $fname($(args...); kwargs...) |
48 | | - if mapreduce(x -> isdefined(Main, x) && isa(getfield(Main,x),Module), &, $weakdeps) |
49 | | - throw(ExtensionMethodError($fname, ($(args...),))) |
50 | | - else |
51 | | - throw(ExtensionLoadError(nameof($fname), $weakdeps)) |
52 | | - end |
53 | | - return nothing |
54 | | - end |
55 | | - end |
56 | | - return eval(expr) |
57 | | -end |
58 | | - |
59 | 10 | """ |
60 | 11 | $(TYPEDSIGNATURES) |
61 | 12 |
|
@@ -313,14 +264,10 @@ function simplexgrid(file::String, ::Type{Val{:sg}}; kwargs...) |
313 | 264 | return g |
314 | 265 | end |
315 | 266 |
|
316 | | -prepare_extension_function(:simplexgrid_from_gmsh, [:Gmsh], [:filename]) |
317 | | -# function simplexgrid_from_gmsh(filename; incomplete = false, Tc = Float32, Ti = Int32) |
318 | | -# throw(ErrorException("Missing Gmsh extension. Add Gmsh.jl to your environment and import it to read msh or geo files.")) |
319 | | -# end |
320 | | - |
| 267 | +@extensionfunction simplexgrid_from_gmsh(filename;incomplete=false,Tc = Float32,Ti=Int32) Gmsh |
321 | 268 |
|
322 | 269 | function simplexgrid_to_gmsh end |
323 | 270 |
|
324 | | -function mixedgrid_from_gmsh end |
| 271 | +@extensionfunction mixedgrid_from_gmsh(filename;Tc = Float32, Ti = Int32) |
325 | 272 |
|
326 | 273 | function mixedgrid_to_gmsh end |
0 commit comments