JuliaGeometry / GeometryTypes.jl

Geometry types for Julia
Other
67 stars 41 forks source link

Quad Faces are incorrectly converted to Triangle Faces #169

Open sjkelly opened 5 years ago

sjkelly commented 5 years ago

I ran into this while working on meshing.

This is the simplest example:

julia> fcs4 = Face{4,Int}(1,2,3,4)
4-element Face{4,Int64}:
 1
 2
 3
 4

julia> convert(Face{3,Int},fcs4)
3-element Face{3,Int64}:
 1
 2
 3

When converting from Quads to Triangles this should return a tuple of Face{3,Int}(1,2,3),Face{3,Int}(3,4,1)

It is possible I am not calling the conversion correctly. It is these lines here: https://github.com/JuliaGeometry/Meshing.jl/pull/20/files#diff-bf57842023cb186f77b74657fbbe3164R224

rdeits commented 5 years ago

I think this convert call should just be an error. Looks like a bug in the FixedSizeArrays compatibility layer, which we should be getting rid of (see #156 ).

However, I think the function you actually want is decompose:

julia> f4 = Face{4, Int}(1,2,3,4)
4-element Face{4,Int64}:
 1
 2
 3
 4

julia> decompose(Face{3, Int}, f4)
([1, 2, 3], [1, 3, 4])
sjkelly commented 5 years ago

I forgot about the decompose functionality. Maybe we need to call it (with some array work) instead of convert here: https://github.com/JuliaGeometry/GeometryTypes.jl/blob/453c2505b2f2cd1024ac4033ad51a9522ec05097/src/types.jl#L187

The quad mesh to triangle mesh conversion is the symptom here. I'll be playing with https://github.com/JuliaGeometry/GeometryTypes.jl/pull/27 and https://github.com/JuliaGeometry/GeometryTypes.jl/pull/166 shortly, so I will try to address then.