|
| 1 | +function GB.Mesh(df::GT.SignedDistanceField{3,ST,FT}, |
| 2 | + method::AbstractMeshingAlgorithm; |
| 3 | + pointtype=GB.Point{3,Float32}, |
| 4 | + facetype=GB.GLTriangleFace) where {ST, FT} |
1 | 5 |
|
2 |
| -""" |
3 |
| - _determine_types_gb(meshtype, fieldtype=Float64, facelen=3) |
4 |
| -Given a subtype of AbstractMesh, determine the |
5 |
| -type of vertex/point and face to use for internal computations. |
6 |
| -Preference is given to the types specified by the Mesh call, |
7 |
| -and will default to the `FieldType` for `SignedDistanceField`, |
8 |
| -and Point{3,Float64}/TriangleFace{Int} for direct function sampling. |
9 |
| -""" |
10 |
| -function _determine_types_gb(pointtype, facetype, fieldtype=Float64, facelen=3) |
11 |
| - # determine the point and face types |
12 |
| - # preference is given to the Mesh types |
13 |
| - # followed by SDF if unspecified |
14 |
| - VertType = if pointtype isa Nothing |
15 |
| - GB.Point{3, fieldtype} |
16 |
| - else |
17 |
| - pointtype |
18 |
| - end |
19 |
| - |
20 |
| - FaceType = if facetype isa Nothing |
21 |
| - GB.NgonFace{facelen, Int} |
22 |
| - else |
23 |
| - facetype |
24 |
| - end |
25 |
| - |
26 |
| - return VertType, FaceType |
27 |
| -end |
28 |
| - |
29 |
| -function mesh(df::GT.SignedDistanceField{3,ST,FT}, method::AbstractMeshingAlgorithm; |
30 |
| - pointtype=nothing, facetype=nothing, ) where {ST, FT} |
31 |
| - |
32 |
| - vertex_eltype = promote_type(FT, typeof(method.iso), typeof(method.eps)) |
33 |
| - VertType, FaceType = _determine_types_gb(pointtype, facetype, vertex_eltype, |
34 |
| - GB.default_face_length(method)) |
35 | 6 | h = df.bounds
|
36 |
| - vts, fcs = isosurface(df.data, method, VertType, FaceType, origin=VertType(GB.origin(h)), widths=VertType(GB.widths(h))) |
| 7 | + vts, fcs = isosurface(df.data, method, pointtype, facetype, origin=pointtype(GB.origin(h)), widths=pointtype(GB.widths(h))) |
37 | 8 | return GB.Mesh(vts, fcs)
|
38 | 9 | end
|
39 | 10 |
|
40 |
| -function GB.mesh(f::Function, h::GB.Rect, samples::NTuple{3,T}, method::AbstractMeshingAlgorithm; |
41 |
| - pointtype=nothing, facetype=nothing) where {T <: Integer} |
42 |
| - vertex_eltype = promote_type(T, typeof(method.iso), typeof(method.eps)) |
43 |
| - VertType, FaceType = _determine_types_gb(pointtype, facetype, vertex_eltype, |
44 |
| - default_face_length(method)) |
45 |
| - vts, fcs = isosurface(f, method, VertType, FaceType; samples=samples, |
46 |
| - origin=VertType(GB.origin(h)), widths=VertType(GB.widths(h))) |
| 11 | +function GB.Mesh(f::Function, |
| 12 | + h::GB.Rect, |
| 13 | + samples::NTuple{3,T}, |
| 14 | + method::AbstractMeshingAlgorithm; |
| 15 | + pointtype=GB.Point{3,Float32}, |
| 16 | + facetype=GB.GLTriangleFace) where {T <: Integer} |
| 17 | + vts, fcs = isosurface(f, method, pointtype, facetype; samples=samples, |
| 18 | + origin=pointtype(GB.origin(h)), widths=pointtype(GB.widths(h))) |
| 19 | + |
47 | 20 | return GB.Mesh(vts, fcs)
|
48 | 21 | end
|
49 | 22 |
|
50 |
| -function GB.mesh(f::Function, h::GB.Rect, method::AbstractMeshingAlgorithm; |
51 |
| - samples::NTuple{3,T}=_DEFAULT_SAMPLES, pointtype=nothing, |
52 |
| - facetype=nothing) where {T <: Integer} |
53 |
| - return mesh(f, h, samples, method; pointtype=pointtype, facetype=facetype) |
| 23 | +function GB.Mesh(f::Function, h::GB.Rect, method::AbstractMeshingAlgorithm; |
| 24 | + samples::NTuple{3,T}=_DEFAULT_SAMPLES, |
| 25 | + pointtype=GB.Point{3,Float32}, |
| 26 | + facetype=GB.GLTriangleFace) where {T <: Integer} |
| 27 | + |
| 28 | + return GB.Mesh(f, h, samples, method; pointtype=pointtype, facetype=facetype) |
54 | 29 | end
|
55 | 30 |
|
56 |
| -function GB.mesh(volume::AbstractArray{T, 3}, method::AbstractMeshingAlgorithm; pointtype=nothing, facetype=nothing, kwargs...) where {T} |
57 |
| - vertex_eltype = promote_type(T, typeof(method.iso), typeof(method.eps)) |
58 |
| - VertType, FaceType = _determine_types_gb(pointtype, facetype, vertex_eltype, |
59 |
| - default_face_length(method)) |
60 |
| - vts, fcs = isosurface(volume, method, VertType, FaceType; kwargs...) |
| 31 | +function GB.Mesh(volume::AbstractArray{T, 3}, |
| 32 | + method::AbstractMeshingAlgorithm; |
| 33 | + pointtype=GB.Point{3,Float32}, |
| 34 | + facetype=GB.GLTriangleFace, |
| 35 | + kwargs...) where {T} |
| 36 | + |
| 37 | + vts, fcs = isosurface(volume, method, pointtype, facetype; kwargs...) |
61 | 38 | return GB.Mesh(vts, fcs)
|
62 | 39 | end
|
0 commit comments